1

I'm working with Solr 4.3.0 and implementing Ajax-Solr for the interface. However, Ajax-Solr does not save state automatically. There is a ParameterStore and ParameterHashStore method but they don't work with legacy browsers. I used my google-fu and found the following but it doesn't work as intended:

https://github.com/evolvingweb/ajax-solr/pull/23

...with a few more resources I came up with this:

<script>
var Manager;
(function ($) { 
Manager.setStore(new AjaxSolr.ParameterHashStore()); 
Manager.store.exposed = [ 'fq', 'q', 'start' ]; 
Manager.init(); 

// Establish Variables
var History = window.History; // Note: We are using a capital H instead of a lower h
    if ( !History.enabled ) {
         // History.js is disabled for this browser.
         // This is because we can optionally choose to support HTML4 browsers or not.
         return false;
     }
     State = History.getState(),

    // Bind to State Change
    History.Adapter.bind(window,'statechange',function(){ // Note: We are using   
statechange instead of popstate
        // Log the State
       var State = History.getState(); // Note: We are using History.getState() instead 
of event.state
        History.log('statechange:', State.data, State.title, State.url);
    });

    // Log Initial State
    History.log('initial:', State.data, State.title, State.url);

})(jQuery);
</script>

But it doesn't work. The Forward and Back buttons are broken in all browsers and nothing gets logged to the console.

What am I missing or is v4.3.0 inherently borked right now and needs a patch?

Would greatly appreciate any help. Thank you!

JsusSalv
  • 517
  • 1
  • 8
  • 22
  • Also, I forgot to mention that Ajax-Solr is NOT exposing the URL parameters even though I added the Manager.store.exposed code – JsusSalv May 24 '13 at 22:09

1 Answers1

1

I know nothing about AJAX-Solr. But I think discussing some few things with you might help.

If AJAX-Solr works the same way the normal AJAX do, then AJAX-Solr will execute some server-side function and outputs it in client-side (of course without refreshing the actual page). As consequence, you should put the function triggering the ajax call inside your History.Adapter.bind(window,'statechange',function().

About State = History.getState(); it is responsible of returning the state data of a pushed state in history stack (url, title, ajax parameters). please to read the doc about hisrory.js on github. Note also that you are using a comma instead of semicolon in your code. In addition, you are calling this function twice. Call it only one time inside your Bind function to get the state parameters and use them in your ajax call (in order to refresh the part of your page while navigating over brower back-forward buttons).

I advise you to read also Back-Forward buttons of browser are showing weird behaviour. History.js, maybe it will help you understand positionning of ajax regarding Bind.

Good luck.

Community
  • 1
  • 1
Adib Aroui
  • 4,981
  • 5
  • 42
  • 94