Hyperlink
clicks doing page refresh in JQuery
$("CallFunctionToOpenWindow(event)’>" Click Here "");
anchor.click(function (event) {
CallFunctionToOpenWindow (event);
event.stopPropagation();
event.preventDefault();
});
Normally if
you have multiple Ajax calls and Hyperlink action on the same page then you
will face multiple call issues, when you clicks on hyperlink same time another Ajax
call action trigger and create the issues, you have to prevent those call using
‘stopPropogation’ and ‘preventDefault’, see below example
Following code will refresh page when you click on “Click
Here”
$("CallFunctionToOpenWindow(event)’>" Click Here "");
Try following way to write same code, this will prevent
server call which will not refresh the page
var anchor = $("CallFunctionToOpenWindow(event)’>" Click Here "");
anchor.click(function (event) {
CallFunctionToOpenWindow (event);
event.stopPropagation();
event.preventDefault();
});
CallFunctionToOpenWindow():
you can write simple custom function to do the action on hyperlink click.
No comments:
Post a Comment