views:

1072

answers:

2

im trying to understand how to use the jquery address plugin for handling deep linking with ajax.

but the documentation is very poor and i cant find any good tutorials explaining what is going on.

i think a good documentation with good examples is important with every plugin.

could someone explain or give some useful links for explanation?

$.address.change(function(event) {  
    // do something depending on the event.value property, e.g.  
    // $('#content').load(event.value + '.xml');  
});  
$('a').click(function() {  
    $.address.value($(this).attr('href'));  
});

i mean, what does $.address.value do? it says "Provides the current deep linking value." what does it even mean? and what does it do with it?

+3  A: 

The plugin seems to have moderate documentation, but if you're looking for something a little more in depth that does the same sort of thing, I would check out jQuery BBQ: http://benalman.com/projects/jquery-bbq-plugin/

It's $.param implementation is being put into jQuery 1.4 and its deparam implementation is currently the only thing that reads that new format. Also, the documentation is great.

Alex Sexton
thx for the link. it looks more "more" than jquery address. do u recommend to use this one instead of address?
weng
I absolutely recommend this one over jquery address.
Alex Sexton
ok, the examples are great! it not just is easy to use, it teaches me how it works...good code + good documentation = good stuff
weng
just one thing i dont quite understand, what is the cache doing? if ( cache[ url ] ) {...}
weng
i understand it now...:)
weng
A: 

A quick tut.: The biggest caveat of using AJAX is that the URL is not changing hence back button is not working + links are not crawled. The workaround for this is to use the page section anchor in the URL, the # sign. Based on the data after the hashsign you can use AJAX, load crawlable pageparts, etc.

The only problem with this that most browsers do not have an URL change event, based on which, the AJAX content can be loaded, so practicly what the plugin is doing is that from time to time it monitors the URL and if it changed, triggers an event based on tha after-hash-sign-parameters. So basically what you do here is

    $('a').click(function() {  
    **//change the after-hash-sign-params to the value of the clicked link**
        $.address.value($(this).attr('href'));

    });
    $.address.change(function(event) { 
 **//define an event handler based on the params...**
         if (event.value = 'sortbyname')
            sortstuffbyname()
else if (event.value ='sortbysomethingelse')
         sortstuffbysomethingelse();
        // do something depending on the event.value property, e.g.  
        // $('#content').load(event.value + '.xml');  
    });  

I never tried the other plugin but working principles are probably the same.

Oras Laszlo