I used a data pager in my application,this shows the <a> tags for paging which is under a span tag, and the name of span tag is the name of the datapage which i given it at .aspx page.
Now my problem is i want to stop _doPostBack function of javascript and use my own function i use the follwing line for that
Code is correct ...it would work for html like this <span id="Pager1"><a>1</a></span>, check generated html to see if it is same. Make sure you write it inside $(document).ready(function(){}); I tested it at my end and its working fine...obviously i replaced
var pageId = $(this).text() with alert($(this).text());
Thanks
Please mark the post as "Answer" that helps you.
Marked as answer by vish02chouhan on May 04, 2012 06:58 AM
Now my problem is it works first time correctly,but when i click second time on this paging ,then my my jquery function is not called and postback occurs
if you have registered the function in document.ready...it should not cause problem if it is normal postback (I assume you are not using updatepanel)...and i dont understand the __doPostBack in href ??
Actualy i use Jquery Load Function to load data and the data it load contains paging by datapager therefore __doPostBack comes in href,actually my problem is solved now i using live in place of bind...
Thanks for your support,if you have some comments on that then i feel pleasured
I would have suggestedt to use "live" if you were using updatepanel....partial postback unregisters the event you write using jquery and recreates the DOM ...."live" attaches event for those newly created DOM elements.
vish02chouha...
Member
303 Points
251 Posts
Problem in paging
May 04, 2012 04:38 AM|LINK
I used a data pager in my application,this shows the <a> tags for paging which is under a span tag, and the name of span tag is the name of the datapage which i given it at .aspx page.
Now my problem is i want to stop _doPostBack function of javascript and use my own function i use the follwing line for that
$("span['id*='Pager1] a").bind('click', function() {
var pageId = $(this).text();
//some code here
return false;
});
But this function not work,i dont understand what is problem
me_ritz
Star
9337 Points
1447 Posts
Re: Problem in paging
May 04, 2012 04:49 AM|LINK
Code is correct ...it would work for html like this <span id="Pager1"><a>1</a></span>, check generated html to see if it is same. Make sure you write it inside $(document).ready(function(){}); I tested it at my end and its working fine...obviously i replaced var pageId = $(this).text() with alert($(this).text());
Thanks
vish02chouha...
Member
303 Points
251 Posts
Re: Problem in paging
May 04, 2012 05:35 AM|LINK
My html is as follows
<span id="ctl00_CPHPackage_Pager1"><span>1</span> <a href="javascript:__doPostBack('ctl00$CPHPackage$Pager1$ctl00$ctl01','')">2</a> <a href="javascript:__doPostBack('ctl00$CPHPackage$Pager1$ctl00$ctl02','')">3</a> <a href="javascript:__doPostBack('ctl00$CPHPackage$Pager1$ctl00$ctl03','')">4</a> <a href="javascript:__doPostBack('ctl00$CPHPackage$Pager1$ctl00$ctl04','')">5</a> <a href="javascript:__doPostBack('ctl00$CPHPackage$Pager1$ctl00$ctl05','')">...</a> </span>Now my problem is it works first time correctly,but when i click second time on this paging ,then my my jquery function is not called and postback occurs
me_ritz
Star
9337 Points
1447 Posts
Re: Problem in paging
May 04, 2012 06:13 AM|LINK
if you have registered the function in document.ready...it should not cause problem if it is normal postback (I assume you are not using updatepanel)...and i dont understand the __doPostBack in href ??
Thanks
vish02chouha...
Member
303 Points
251 Posts
Re: Problem in paging
May 04, 2012 06:17 AM|LINK
Actualy i use Jquery Load Function to load data and the data it load contains paging by datapager therefore __doPostBack comes in href,actually my problem is solved now i using live in place of bind...
Thanks for your support,if you have some comments on that then i feel pleasured
me_ritz
Star
9337 Points
1447 Posts
Re: Problem in paging
May 04, 2012 06:23 AM|LINK
I would have suggestedt to use "live" if you were using updatepanel....partial postback unregisters the event you write using jquery and recreates the DOM ...."live" attaches event for those newly created DOM elements.
http://api.jquery.com/live/
Thanks