I have a button on my page that does an Ajax开发者_如何转开发 callback with an onclick javascript method. I want to re-register ALL the Javascripts on the page after the ajax is completed. I have a common init method that I call on ajaxComplete with some functions called after ajax completion.
However, there are several javascripts, and in different files. Is it possible to get all the javascript files (based on the file names on the server) and re-register them onAjax complete?
I am using C#/.NET (.NET ajax) and if there's a way to register the files via code behind (on ajax complete).
Currently I have a javascript method that is called on ajax completion, is there any way to place this inside code-behind to re-register the javascripts?
Personally, I would load all the javascript I needed right off the bat. This alleviates complexity and makes small nuisances like naming conflicts easier to troubleshoot.
However -- if you still want to go with the dynamic loading route, then all you need to do is create a js function that dynamically loads the files you need (multiple ways to accomplish this) and register that function with the scriptmanager on the page for subsequent calling. If you're not keen on using the scriptmanager, then you'll need to call the aforementioned script-loading function you created from within your onAjaxComplete function.
For thoroughness, I should add that there are some really good dynamic script loading libraries available.
精彩评论