问题
I am using a Data View control and the Pager Add Rows control to allow the user to add more rows to the data view.
Can I extend the Pager Add Rows control to automatically add rows to the Data View when the user reaches the bottom of screen?
回答1:
Yes, you can do that easily with jquery. if you master dojo you can probably do it in similar ways. but this example show jQuery.
- add jQuery to your xpage
- add a new custom scriptlibrary to your xpage
- put below code in your custom scriptlibrary
- Add a addPageRows control to your xpages and connect it to a repeat.
- All set, try it out.
$(function(){ $(window).scroll(function(){ if($(window).scrollTop() == $(document).height() - $(window).height()){ $("[id$='pagerAddRows1_ar'],[id$='pagerAddRows2_ar']").click(); } }); })
The jquery code will try and find pagerAddRows1_ar or pagerAddRows2_ar and if found will click the link automatically when you reach the bottom of screen.
You can actually use this code with any kind of pager or link you have on your xpage. just make sure your code click the right id.
来源:https://stackoverflow.com/questions/9225101/automatically-add-rows-to-a-data-view