How can I force a jQuery plugin to refresh the data it has loaded?
I am working with jQuery Pagination, and a popup form. On saving the data in the form, how would I go about forcing the Pagination plugin to reload the data it would load for whatever page I am on, without reloading the entire webpage?
Ex: Item 1 Item 2 Item 3
Add Item->Item 23->Save->Reload 开发者_如何学编程List
Item 1 Item 2 Item 3 Item 23
http://d-scribe.de/webtools/jquery-pagination/lib/jquery_pagination/README
http://plugins.jquery.com/project/pagination
The only thing I could think of to do in this situation (and I am not positive it would work) is to call the pagination initialize function again. So you would add the new element, and then call it again like this,
function addNewElement() {
$.create('div', {}).appendTo("container");
$("#container").pagination(numElements, {
items_per_page:20,
callback:handlePaginationClick
});
}
Now, I have never used this plug-in before, but I dont think that there is any other way to "reload" the content since the plug-in does not give you that option. Also, hopefully this overwrites the first call that you made and does not add it onto the first call.
I used the domec plug-in here with the $.create. Just know that is where you create your new element.
Hope this helps!
Metropolis
I looked, but I could not find the source for the plugin. My guess would be you will need to add a 'update' function to the plugin that refreshes the data it is using. Short of that, you will need to unload and reload it.
精彩评论