csierra
Posts: 123
|
Posted: 05/25/2011, 8:30 AM |
|
Hi, I have the need of refactoring the way codecharge binds events (clientside) because often breaks ajax results; specially with script intensive componets such as editable grid or CCSTools js treeview; how can I change this
<script language="JavaScript" type="text/javascript">
//End Include Common JSFunctions
//_OnLoad @1-9C4F01C0
function _OnLoad()
{
var result = true;
//End _OnLoad
//CCT Generate Tree @13-D255D513
// This action generates needed files for JavaScript Tree
//End CCT Generate Tree
//Close _OnLoad @1-BC33A33A
return result;
}
//End Close _OnLoad
//bind_events @1-B4BAE7CE
function bind_events() {
addEventHandler("", "load", _OnLoad);
}
//End bind_events
window.onload = bind_events; //Assign bind_events @1-19F7B649
//End CCS script
</script>
Into a wrapped set of function calls and trigger them by call instead of window.onload; window.onload is no longer evoked since by when I am appending content to the page, the DOM has been already finished and loaded... One of the ideas I have is just make the inline script like
<script type="text/javascript">
function init_page(){
// do the stuff here
}
</script>
Then I came across that several pages are consumed within the same consumer, so I would be calling several times page_init after AJAX XHR response rendered into the consumer proper container, redundantly attaching events or triggering stuff... that was solved by using jquery and calling the functions with particular names, e.g.
function init_page_layouts(){ ... and init_page_sitemap(){ ... and use jquery to match some metadata on the consumed page, such as title to trigger only once, so far so good BUT
What about events recurring, e.g. clicking on a div, or an onblur etc? different scenario is when code needs to execute once such as in the example (window.onload) that can be done with a single call, different thing with recurring events;
WHY CANīT CODECHARGE JUST DROP TO THE GARBACHE prototype and start supporting jQuery? is by far more easy, more powerful and much more widely supported, letīs face it, is kind of a standard by now, event MS Visual Studio and Aptana's IDE are supporting it.
Thanks for any ideas
_________________
Yes! I Can!!! |