jquery for ruby on rails
- by Cezar
Hello,
I am tying to use this code http://gist.github.com/110410 to dump Prototype in favor of jQuery but I do have a problem.
This is my HTML (a link_to generated link):
<a onclick="var f = document.createElement('form'); f.style.display = 'none'; this.parentNode.appendChild(f); f.method = 'POST'; f.action = this.href;var s = document.createElement('input'); s.setAttribute('type', 'hidden'); s.setAttribute('name', 'authenticity_token'); s.setAttribute('value', 'Mi6RcR6YDyvg2uNwGrpbeIJutSHa2fYboU37wSDE7AU='); f.appendChild(s);f.submit();return false;" class="post add_to_cart " href="/line_items?product_id=547">Add to cart</a>
Issue:
Everything works as it should except that the page does a reload. I suspect that the submit gets thru which causes a page reload.
Is there an elegant way to prevent that ? return false; doesn't seem to cut it in this case.