Note that there are some explanatory texts on larger screens.

plurals
  1. PODouble remote call with jQuery Address plugin and Rails 3 remote links
    primarykey
    data
    text
    <p>I'm using this jQuery plugin <br /> <a href="http://www.asual.com/jquery/address/" rel="nofollow noreferrer">http://www.asual.com/jquery/address/</a> <br /> because I have a full ajax site hacked in <code>Rails 3.1.0</code> but my actions/methods also respond to html requests.</p> <p>so if I have a link</p> <pre><code>&lt;%=link_to "my link",{:controller=&gt;"my_controller",:action=&gt;"my_action"},:remote=&gt;true%&gt; </code></pre> <p>It'd do the call but URL will stay the same and if i share the URL you'll be always looking at the root page <code>/</code> page but with this plugin i get to call the remote method of <code>my_controller</code> and also change the displaying url with</p> <pre><code>var elemetns = $("a.addressPlugin"); $.address.crawlable(1).state('/').init(function(){ elemetns.address(); }); </code></pre> <p>my new link</p> <pre><code>&lt;%=link_to "my link",{:controller=&gt;"my_controller",:action=&gt;"my_action"},:class=&gt;"addressPlugin",:remote=&gt;true%&gt; </code></pre> <p>now my url looks like</p> <pre><code>http://localhost:3000/my_controller/my_action </code></pre> <p>but when i hit back on the browser it the page stays with no change</p> <p>then I figured it to to do this</p> <pre><code>var elemetns = $("a.addressPlugin"); $.address.crawlable(1).state('/').init(function(){ elemetns.address(); }).change(function(e){ $.ajax({type:'GET',url:e.path,dataType:'script',cache:true}); }); </code></pre> <p>so now it does the trick backward and forward but ....</p> <p>when i Click the link it does the remote call twice.... once for the link itself and one for the <code>.change(...</code> method.... but when I go backwards it works perfectly it only does the call once on the <code>.change(...</code> method.... so</p> <p>How can I prevent the <code>$.ajax</code> call to be made only when going backward and forward on the browser and not when clicking links because they already do the call by them selves?</p> <p>&lt;&lt; -- UPDATE -- >> <br /> In Safari and Chrome browsers when I get in history one step back from my main page and then I navigate forward with the browser's buttons I get a complete white screen displaying only the javascript function that loads my <code>main/index</code> view via ajax but there's only that in the browser</p> <p><img src="https://i.stack.imgur.com/tlKir.png" alt="Javascript Function Displaying instead of webpage"></p> <p>&lt;&lt; -- UPDATE -- > <br /></p> <p>Basically this is what I'm trying to replicate but using ruby on rails and their <code>remote links</code></p> <p><a href="http://www.asual.com/jquery/address/samples/state/" rel="nofollow noreferrer">http://www.asual.com/jquery/address/samples/state/</a></p>
    singulars
    1. This table or related slice is empty.
    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.
 

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