jquery - Call javascript functions when Partial view is rendered -


i rendering partial view create popup when create button clicked.

this means dynamically div appended main view on button click.

after div generated , elements inside loaded, after want call javascript functions.

all answers able find using .load() event, scenario different. not loading partial view div using ("#div").load(url, function(){}); div generated dynamically

please suggest

javascript executed synchronously. if building "the view" using jquery , inserting dom, execute "post render" code after markup inserted dom.

$('#mycontainer').append(somemarkup); execsomepostrenderfunction(); 

if using ajax load partial view/html content server use load() function , put post render code in callback.

$('#mycontainer').load('route/to/partial', execsomepostrenderfunction); 

or can use anonymous function:

$('#mycontainer').load('route/to/partial', function(){     //...do here }); 

your question little confusing because have question tagged ajax not loading partial view. might want specify mvc framework using can give more targeted guidance.

partial views in asp.net mvc, example, server-side technology , way render partial view after page has loaded (like on button click event) through ajax , load() function (you use $.get() or $.ajax() load() easier; that's why created).


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -