I have written some code in jsp
$(document).ready(function() {
$("#invDiffAccount").trigger("change");
$("#adatAccount").trigger("change");
$("#originalInvNo").trigger("keyup");
$("#originalInvNo").keyup(function() {
//////calling json //////
});
$('#confirmationParty').change(function(){
///setting some label values///
});
$('#invDiffAccount').change(function(){
///setting some label values///
});
$('#adatAccount').change(function(){
///setting some label values///
});
});
My problem is when i am getting any validation message and page redirects to same page
it should execute all these functions since i have written it into document.ready
Can anybody tell me why it’s not happening ..???
If you trigger an event before you attach its handler, the handler will not be called. If this is what you’re trying to do, first attach, then trigger.
If you want to trigger a handler if a page is reloaded, you need to do it in a different way. The event handlers won’t survive a page reload:
SessionStorageobject persists its contents when the user navigates to a different page on the same domain.refererheader when navigating to the page, containing the URL of the previous page. Some browsers don’t do it, though.if($("#my-form-error").length){...<script> shouldTriggerX = true`. Be careful about polluting the global scope, though.<script> $(document).ready(onFormSubmitDone) </script>. This has the same problem of polluting the global scope.body):if($(body).is(".form-error-page"){...