jquery - How to not use JavaScript with in the elements events attributes but still load via AJAX -
i loading html content via ajax.
i have code things on different elements onclick
attributes (and other event attributes).
it work, starting find code getting rather large, , hard read. have read considered bad practice have event code 'inline' , should element.onclick = foobar
, have foobar
defined somewhere else.
i understand how static page easy this, have script tag @ bottom of page , once page loaded have executed. can attach , events need them.
but how can sort of affect when loading content via ajax. there slight case content loaded can depending on in database, times sections of html, such tables of results, not displayed there else entirely.
i can post samples of code if body needs them, have no idea sort of things people one. point out, using jquery if has helpful little functions rather sweet!
small code sample
this sample of code loaded via ajax request
<input type="submit" name="login" value="login" onclick=" if(check_login(this.form)){ window_manager.windows[1].load_xml('login/display.php?username=' + this.form.username.value + '&password=' + this.form.password.value); } else { return false; }">
i know small sample, sort of thing on about. how can have code attached when content loaded?
jquery .live() method looking for. attach click event newly created html elements, don't need call .click() every reload of update-panel.
Comments
Post a Comment