Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery Bind Events Don't Respond
    primarykey
    data
    text
    <p>I'm trying to basically increment and decrement a vote count when a button is pressed (I've dumbed down the situation to exploit my error); I bind two different buttons with click events;however, I fail to get any response out of them (tested with Firebug).</p> <p>Jquery Code:</p> <pre><code>//This Code is located within Application.js (Rails) $(document).ready(function() { $('.buttonUp').bind('click', function() { var voting_element = $(this).closest('.current_vote'); voting_element.text( Number(voting_element.text()) + 1 ); }); $('.buttonDown').bind('click', function() { var voting_element = $(this).closest('.current_vote'); voting_element.text( Number(voting_element.text()) - 1 ); }); }); </code></pre> <p>Each button with class buttonUp or buttonDown is located within a form containing the single submit button.</p> <p>I am doing this in Rails 3.1.3 and using the following versions of the Jquery Library:</p> <p>Jquery-Rails => 1.0.12<br> Jquery => 1.6.1<br> JqueryUI => 1.8.12<br> JqueryUJS => The one that comes with Jquery-Rails above.</p> <p>Live doesn't work either, I wasn't expecting it would since I wait for the document to load before I bind the methods to the buttons.</p> <p>Here is a snippet of the HTML in question.</p> <pre><code>&lt;tr&gt; &lt;td&gt;pop&lt;/td&gt; &lt;td&gt;pop&lt;/td&gt; &lt;td&gt;&lt;a href="/posts/12"&gt;Show&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="/posts/12/edit"&gt;Edit&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;a href="/posts/12" data-confirm="Are you sure?" data-method="delete" rel="nofollow"&gt;Destroy&lt;/a&gt;&lt;/td&gt; &lt;td&gt;&lt;p&gt; &lt;b&gt;votes: &lt;/b&gt; &lt;/p&gt; &lt;p class="current_vote"&gt; 1 &lt;/p&gt; &lt;form action="/posts/increaseVote?id=12" class="button_to" data-remote="true" data-type="json" method="post"&gt;&lt;div&gt;&lt;input class="buttonUp" type="submit" value="increaseVote" /&gt;&lt;input name="authenticity_token" type="hidden" value="TxEGwONzSD+tnJ19iHMdGjuCBJMFoNJdECEspDtZxxY=" /&gt;&lt;/div&gt;&lt;/form&gt; &lt;form action="/posts/decreaseVote?id=12" class="button_to" data-remote="true" data-type="json" method="post"&gt;&lt;div&gt;&lt;input class="buttonDown" type="submit" value="decreaseVote" /&gt;&lt;input name="authenticity_token" type="hidden" value="TxEGwONzSD+tnJ19iHMdGjuCBJMFoNJdECEspDtZxxY=" /&gt;&lt;/div&gt;&lt;/form&gt; &lt;/tr&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload