caching - Cache issue with javascript -
i have javascript code detect fields changes on page. working ie unfortunately not in chrome. don't know why happening. when try access via different browsers , units. javascript not working well. need clear cache history make work properly. here's code:
var ctr = 1; var isfirstload = true; function propertychangedbycode() { ctr = 0; propertychanged(); } function propertychanged() { if (document.readystate == "complete") { $('[id$=savebutton]').removeattr("disabled"); $('[id$=savebutton]').removeattr("class"); $('[id$=savebutton]').addclass("btn btn-primary"); warnmessage = 'warning: have unsaved changes.'; console.log(ctr); window.onbeforeunload = function () { if (ctr == 0) { return warnmessage } else if (ctr == 1) { ctr = 0; } } } } $("body").click(function (event) { console.log(event.target); if (event.target.type == "submit" && event.target.value != "save" && event.target.value != "cancel" && event.target.value != "next") { ctr = 0; propertychanged(); console.log("body clicked"); } }); function pageload() { jquery("input.datepicker").dp({ dateformat: 'm d, yy', altformat: 'yy-mm-dd', buttontext: '<i class="icon icon-calendar"></i>', showon: 'both' }); $("button.ui-datepicker-trigger").addclass('btn right'); console.log("pageonload: " + ctr); var warnmessage = 'warning: have unsaved changes.'; $('input[type="text"],select,textarea').each(function (k, v) { var elem = $(this); // save current value of element elem.data('oldval', elem.val()); // changes in value elem.bind("change keyup input paste", function (event) { ctr = 0; // if value has changed... if (elem.data('oldval') != elem.val()) { propertychanged(); } }); }); $('.btn').click(function (e) { console.log("whatever"); ctr = 1; }); //ui-datepicker-trigger $('.ui-datepicker-trigger').click(function (e) { console.log("date"); ctr = 0; }); if (isfirstload) { window.onbeforeunload = null; $('[id$=savebutton]').attr("disabled", "disabled") console.log("disable"); isfirstload = false; }
so this, decided take on path on disabling caching on system. put code on master page page_load.
response.cache.setcacheability(system.web.httpcacheability.nocache) response.cache.setnostore() response.cache.setallowresponseinbrowserhistory(true)
base on research, these 3 lines disable caching in application. tried clear cache, inputted values on field, hit save, , browse again page still fields presenting previous input in autofill. i'm assuming disabling of caching won't work. have ideas why disabling of caching not workin? have suggestions regarding browsing caching? , why think i'm experiencing issues need clear cache in order make javascript work properly? lastly, why working on ie not in chrome? thanks! sorry load of questions.
Comments
Post a Comment