I do not understand why I have to click on the link twice in JQuery:
$(function(){
$("#more_reviewers").click(function(){
$("#reviewer_list").html("<%= escape_javascript(render 'restaurants/restaurant_reviewer_list', :venue => @restaurant, :limit => @restaurant.reviews.count) %>");
});
});
When I click, the view overrides the limit on the reviwers shown and shows all the reviewers. What I don't get is why I need to click on the same button twice. None of the other answers to similar questions have worked for me because the problem involves cookie reliance, or somehting else which I'm not doing.
I just tested one more thing: when I put an alert showing the event type, it shows nothing the first time (as if the JS script wasn't bound to the link) then the second time it alerts with the right event type ("click").
The link with ID "more_reviewers" is as follows in rails:
<%= link_to "more", "#", :id => "more_reviewers", :remote => true %>
The link shows the right items, but only after being clicked twice (the first time, nothing appears to change on the page)
Help will be very appreciated.
:remote => truefrom yourlink_to. That's only useful if you want to use Rails' built in functionality for Ajax, but you are writing the Javascript bindings yourself, so it's useless and causes this unwanted effect of having to click twice.