Dom Css在jQuery Pagination Wordpress小部件后丟失了

[英]Dom Css lost after jQuery Pagination Wordpress widget

I have developed a widget for Wordpress to show portfolio, the user can choose if he wants pagination, filter categories, the number of post per page...and so on, it works all perfectly with a php pagination system i have made.


I am trying to implement an ajax jquery to this pagination in widget to make it reload without reloading the whole page. I have this code:

我試圖在小部件中為這個分頁實現一個ajax jquery,使其重新加載而不重新加載整個頁面。我有這個代碼:

jQuery('.paginate a').live('click', function(e){ 

var link = jQuery(this).attr('href');  
jQuery('.widget_gantry_portfolio').html('<div class="loading"></div>');
jQuery('.widget_gantry_portfolio').load(link+' .widget_gantry_portfolio .portfolio_class');

The pagination works perfectly in php, when I implement this code the pagination works but when clicked the widget losses all the user preferences(show filter, show pagination..etc), the divs also loose their calculated % width and height that was firstly present in css(seen in firebug):

分頁在php中完美運行,當我實現此代碼時分頁有效,但是當單擊小部件時會丟失所有用戶首選項(show filter,show pagination..etc),div也會松開他們計算出的首先出現的%寬度和高度在css(在firebug中看到):{width and height}

I have been several days around this and have prove instead of live, on and delegate, and so on, but none of them work, this ajax pagination is working also perfectly in posts pagination on my site but the widget does´nt reload Dom elements?


The most important thing for me are:


-Each of the elements missing width and height, that was in DOM css, firstly this width is calculated with a functions.php enqued script that goes like this for example when it has 4 columns:

- 缺少寬度和高度的每個元素,在DOM css中,首先使用functions.php enqued腳本計算此寬度,例如當它有4列時:

var mysizes = function() {
    theWidth4 = jQuery(".mosaic-block4c img").css('width');
    jQuery(".mosaic-block4c").css('width', theWidth4);
    theHeight4 = jQuery(".mosaic-block4c img").css('height');
    jQuery(".mosaic-block4c").css('height', theHeight4);

I call the mysizes(); function from the widget php with a tag


-The filter of categories missing i think because, when pagination load, doesn't recognizes the user presets for widget.It recognizes it perfectly in first page but no in subsequent pages.

- 缺少類別的過濾器我認為,因為,當分頁加載時,不識別用戶的小部件預設。它在第一頁中完全識別它,但在后續頁面中沒有。

Link to the site with portfolio widget pagination not working properly (please click 2 page to see):


Link to a sample category with this same pagination working (pagination at the bottom of page):


1 个解决方案



From Jure C. comment:

來自Jure C.評論:

A quick look shows that you're at least changing HTML structure. On paginated page you have .portfolio_class twice nested while original is only once.




  © 2014-2022