I'm using this jQuery plugin
http://www.asual.com/jquery/address/
because I have a full ajax site hacked in Rails 3.1.0
but my actions/methods also respond to html requests.
so if I have a link
<%=link_to "my link",{:controller=>"my_controller",:action=>"my_action"},:remote=>true%>
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 /
page but with this plugin i get to call the remote method of my_controller
and also change the displaying url with
var elemetns = $("a.addressPlugin");
$.address.crawlable(1).state('/').init(function(){
elemetns.address();
});
my new link
<%=link_to "my link",{:controller=>"my_controller",:action=>"my_action"},:class=>"addressPlugin",:remote=>true%>
now my url looks like
http://localhost:3000/my_controller/my_action
but when i hit back on the browser it the page stays with no change
then I figured it to to do this
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});
});
so now it does the trick backward and forward but ....
when i Click the link it does the remote call twice.... once for the link itself and one for the .change(...
method.... but when I go backwards it works perfectly it only does the call once on the .change(...
method.... so
How can I prevent the $.ajax
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?
<< -- UPDATE -- >>
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 main/index
view via ajax but there's only that in the browser
<< -- UPDATE -- >
Basically this is what I'm trying to replicate but using ruby on rails and their remote links