Made some modifications to my code and had another thought

$.history.callback = ...Same as previous post

However to store the history now I do the following.

$('#agent_id').change(function() {
                var agentBrowser = $('#AgentBrowser').html();
                $.history({'agentBrowserHTML':agentBrowser});
                window.location = 'index.php?action=view_user&user=' + 
$(this).val
();
});

Thus it seems to me that when agent_id is changed it should store the
AgentBrowser html and redirect the user to the view user page. However
when I use the back button in the browser it seems that one of two
things happens: $.history.callback doesn't get called at all, or it
gets called but the reinstate object is still undefined. Does this
have something to do with my redirecting the page? It does call
$.history.callback at least some of the time, I get the alerts from it
but my AgentBrowser data is never there. Please help! I don't have a
cent to my name unless I can get this project finished, and this is
the last thing I need to do, keep it from breaking when the user hits
the back button on the browser.

~Eric

On Mar 4, 2:05 pm, NightWatchman <rushi...@gmail.com> wrote:
> I'm making a website that has a drill-down form in it where you can
> select an office from a dropdown and then an agent from that
> particular office. My problem is once the user views an agent and
> clicks the back button on the browser my page breaks. I need to retain
> some page states in the form of HTML markup so that when the user
> clicks the back button on the browser I can show them the same page
> state they were looking at. After the intial page load all the new
> content is provided using Ajax post calls. It seems to me thatjHistorywould 
> be perfect for doing this but unfortunately in the
> $.history.callback function there doesn't seem to be any valid
> reinstate object to get the old data from. Can anybody help me figure
> out why? Here is my code.
>
> $.history.callback = function(reinstate, cursor) {
>         alert('history called back');
>         // reinstate if not back at beginning
>         if (typeof(reinstate) != 'undefined') {
>                 $('#AgentBrowser').html('called back browser');
>         }
>         else {
>                 alert('reinstate undefined');
>         }
>
> };
>
> and the function where the history object is instantiated...
>
> function attachFormEventHandlers() {
>         // office_id
>         $('#office_id').change(function() {
>                 
> $.post('index.php?action=addon_agentsearch_get_new_office_html',
>                                                 {office: $(this).val()}, 
> function(new_html) {
>                         var new_browser = $('#AgentBrowserHTML', 
> new_html).html();
>                         ...some unrelated code...
>                         // update agent browser
>                         $('#AgentBrowser').html(new_browser);
>                         // retain browser state
>                         $.history({'agentBrowserHTML':new_browser});
>                         // retain last form action in page so that when the 
> user
>                         // pages through the agents it can re-build the agent 
> list
>                         $('#Control').val('office_id');
>                 });
>         });
>
> }
>
> When the page is run and the back button is clicked on the browser
> after viewing an agent the $.history.callback function alerts that
> reinstate is undefined and the page content does not get changed.

Reply via email to