Can't post, edit, or preview comment when using disable buttons settings

Platinum - November 14, 2009 - 06:18
Project:Hide submit button
Version:6.x-1.9
Component:Code
Category:bug report
Priority:normal
Assigned:Optalgin
Status:needs work
Description

Noticed that I couldn't post, edit, or preview a comment when I'm using the disable buttons option as the script mode.

#1

Optalgin - November 19, 2009 - 13:24

This is a good one :-)

This is really strange, the scripts for hide -or- disable are very close
I have no idea why hiding works for both nodes and comments
and disabling works for nodes but fails for comments ?!?

* I also noted the pointless image preload..

I'll try to analyze it.. any javascript advises are welcome

<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery("<img>").attr("src",'/sites/all/modules/hide_submit/images/loader.gif');
$(document).ready(function() {

    $('input:submit:not(.hide-submit-exclude)').click(function() {
      $(this).siblings('input:submit').attr('disabled', true); $(this).attr('disabled', true);
    }) 
})
//--><!]]>
</script>

#2

Optalgin - December 9, 2009 - 16:27
Component:Miscellaneous» Code
Assigned to:Anonymous» Optalgin
Status:active» needs work

I think I found a solution..
I'll add it soon to the dev. release for testing

The problem is that disabled buttons are not included in the form POST variables
Drupal comment module uses the "op" variable to know which button was pressed (preview/save)
but it is not there because buttons are disabled.

so my current solution is to inject a hidden form element named "op" and assign the value of the clicked button to it.

// HTML
...
<input type="hidden" name="comment-fix" id="hide-submit-comment-fix" value=""  />
...

// jQuery script
   ...
   $("#hide-submit-comment-fix").attr("name", "op");
   $("#hide-submit-comment-fix").attr("value", $(this).attr("value"));
   ...

 
 

Drupal is a registered trademark of Dries Buytaert.