.net - With a single Javascript for Entire Website set on Master Page, how to exe a JS function only for one(or 2) chlid page -


i working on .net website single javascript (so far). because have been told single js best performance etc. firstly, suggestions on js frameworks , cutting-edged articles?

secondly, met problems when trying invoke js function child page. tried :

1.i want exe function after page_load (i.e. ispostback)

$("#div_id").ready 

2.exe function after page postback (a dropdownlist post in updatepanel)

pgregmgr.add_beginrequest(beginhandler)  function beginhandler() {$(".ddl_classname").change(function{.....}); } 

both not work. system won't recognized div or ddl. i'm not able set function in $(document).ready or .add_beginreqest() in 'master' js, cause errors on other pages. suggestions? or have move multiple js files?

moreover, instead of writing inline javascript, i'm using

$(document).ready(function{textchange});  function textchange(function { $(".textbox_class").change(.....)}); 

it works in chrome etc, not ie 7 (mb ie8 well)

can me?

thanks lot.

there's couple different ways this.

personally, don't see wrong having $(document.ready( on each page. keep functions in single .js file, pretty handy (and still lightweight) have simple init functions on each page. in case same thing had:

//on single page want function called on $(document.ready(function() {      textchange(); }); 

if don't want have $(document).ready() on child page, use if statement in .js file. use window.location.pathname path file, , check against should child page. code might :

//in main .js file $(document).ready(function() {      if(window.location.pathname == "/childpage.htm")           textchange(); }); 

Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -