So yeah as the title says, whenever I supply an onclick parameter to my link, it processes the resulting action as HTML in place of JS. Any ideas?
link_to "/profile/share?id=#{post.id}", :id => "share_#{post.id}", :remote => true do "stuff" end
link_to "/profile/share?id=#{post.id}", :onclick => "javascript:$('#share_#{post.id}').text('Loading...')", :id => "share_#{post.id}", :remote => true do "stuff" end
You could have a separate script that binds your custom event handler:
You’ll need to add the ‘.share-link’ class to all the links you want to act like that, but once you’ve done that it should work like you want. This method will have jQuery (which I assume you’re using, from your code sample) bind the event handler, leaving the ‘onclick’ attribute free for Rails to use for AJAX purposes.
Hope this helps!