Click here to Skip to main content
15,908,254 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
i am working on a mvc project and on the index page i have to a table and it can be sorted eg Code

i have got the some javascript to register on document. ready eg$(document).ready(function() {
var _orgId;
var _collectionId;
var _orgName;
var _collectionName;
var _orgCode;
$('.deleteOrganisation ').click(function() {...}

javscript fucntions are working very first time the page is loaded but when i click on the "Code" sort hyperlink the page reload with the new data and at that point javascript funcitons are not working. what am i missing appreciate your help

What I have tried:

what i have seen is the javascript document .ready fair on page load first time or when i refresh the browser but not on the after page load by click on the hyperlink
Posted
Updated 20-Jun-17 23:06pm
Comments
F-ES Sitecore 20-Jun-17 12:09pm    
If deleteOrganisation is removing elements from the page remember that any events on those elements are also removed, and if you replace those elements with new elements they won't have the events attached. When you create your new elements you have to re-attach the events to them again.

Alternatively look at event delegates via jQuery but they don't perform as well.

There is no 'load' or 'ready' event after postback... You have to manually run that code as part of your click event handler...
 
Share this answer
 
There is another way to reload your jquery event

$(document).ready(function() {
    // bind your jQuery events here initially
});

var prm = Sys.WebForms.PageRequestManager.getInstance();

prm.add_endRequest(function() {
    // re-bind your jQuery events here
    loadscript();

});


$(document).ready(loadscript);

function loadscript()
{
  //yourcode 
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900