javascript - Loading extensions manually and best practices for using Ajax for renderPartial -


in yii application i'm using tabs , loading content per ajax renderpartial(). not load scripts multiple times i've set processoutput false. want load needed scripts manually once @ index page.

also use extensions on page. need load js/css manually also. question is:

  • how can figure out extensions used on page , load js/css files?
  • another problem is: example, use bootstrap extension. extension has assets folder, contains many javascript files. how can import files?

i hear best practices loading same content (gridview) ajax without getting duplicate ajax requests when using fitlers/delete buttons.

how can figure out extensions used on page , load js/css files?

you have load files before use them. has done manually. use function require('script.js') before access of it's functions.

your require() method should check if script loaded, , if not perform ajax request.

you can use requirejs perform task you.

another problem is: example, use bootstrap extension. extension has assets folder, contains many javascript files. how can import files?

you have import each file seperatly, means application needs know files.

a idea make config file: content.json. function first fetches config file contains bootstrap-resources. afterwards, fetches these resources.

i hear best practices loading same content (gridview) ajax without getting duplicate ajax requests when using fitlers/delete buttons.

write wrapper function around ajax() caches results.


Comments