By isamir on
hi, I have a page that has a view with ajax pager.
the pager is working fine when the page first run.
the page has a button that loads the next page using ajax, the view is loaded fine but the ajax pager is not working properly, just links without ajax (open pages directly).
how to make ajax pager work when loading a view via ajax, I'm using Drupal 7.28 with views 3.8
p.s. I think ajax view events needs to be rebinded to the pager links after loading the view through ajax, but I can't figure out how to achive that.
Comments
Are you using the build in
Are you using the build in views pager with ajax enabled (under advanced settings)?
Is there more than one pager on the page?
yes I'm using the built in
yes I'm using the built in views pager with ajax enabled.
no, there is only one pager, and it works fine when the page first load,
but when I load the page using ajax the pager stops working as it should be.
Do you get any kind of error
Do you get any kind of error in browser's console
no, I got no errors.
no, I got no errors.
the view is loading fine, but the click events on pager links is not binded so the ajax is not working.
here is a reference fo the website I'm working on (the pager is not implemented yet):
http://alshari3.com
- when you click on next and previous arrows the container(page) is loaded via ajax.
- now I want to attach an ajax pager to the middle block (the one with 9 news thumbnails) --currently I'm working on a local version of the website--.
- the pager is working fine when I first load the page, but when I load the page using the arrows(ajax) , the pager ajax navigation is not working any more
This
This
suggests you have 2 pagers which will cause problems unless you give one of them a different index (views pager setting)
you have missed the point,
you have missed the point, there is only one pager at the same time.
I just empty the container then load the same view again with diffrent argument,
so basically I replace the view with another one via ajax.
How are you loading the other
How are you loading the other view by ajax? I am guessing it's missing a "step".
sorry for late reply,
sorry for late reply,
I have a custom page.tpl (page-ajax.tpl) of the original page.tpl, that I load using jquery load function.
I also have custom html-ajax.tpl that I load when calling page-ajax.tpl to strip javascript and css and other HTML markup so that I only load
the inner html of the page. (note the necessary javascript, css, HTML markup have been loaded for the page first run).
I guess the problem is when I strip the javascript from the loaded page, but I can't load the whole javascript files (because this will result in duplicate files loading and duplicate javascript code). so how to load only the required javascript(which I don't know) that is necessary to run the ajax pager.
I hope I could make it clear.
please refere to this website, it might give you and idea about how I load the inner container with ajax when you navigate the website sections.
http://alshari3.com/
Drupal has an API for loading
Drupal has an API for loading by ajax, the developers module includes several examples. Using the API should cause elements that depend on JS to initialize correctly.
=-=
Are you passing the new
Are you passing the new settings back from your AJAX call? And are you calling Drupal.attachBehaviors() after inserting your new code into the page?
Contact me to contract me for D7 -> D10/11 migrations.
Are you passing the new
No, I don't know what does that mean
No, I do not use Drupal.attachBehaviors().
I might do it the wrong way, sorry I'm very new to drupal and this is my first drupal project.
I will try to explain what I did exactly:
- I have a normal drupal page with some views blocks.
- I load this page whith different taxonomy terms to change the page contents accordingly ex:(http://alshari3.com/ar/taxonomy/term/3/).
- I have a javascript function to load each different page via ajax, with a parameter "loadPageAjax=1".
- in "template.php" ,in theme_preprocess_html() function I check for the variable loadPageAjax, and load a cutom html.tpl and page.tpl pages with no javascript, css, or wrapping HTML markup code, (just the inner content).
- in the javascript ajax function callback I replace the current page container content with the loaded content.
- after that in the ajax callback I recall (rebind) any custom javascript functions required for my page, [except for the drupal views where comes my problem].
**** a snapshot for the javascript function:
***** a snapshot for the theme_preprocess_html() function
hope I could make things clear,
Drupal has an API for loading
Drupal has an API for loading parts of pages by AJAX and there are modules that all ready do this sort of thing.