开发者

jquery widget include files

开发者 https://www.devze.com 2023-02-09 23:52 出处:网络
Is it possible to create jquery widget开发者_运维百科 include files that ONLY contain one specific widget?If I use the custom ui download builder then it insists on including the ui core.I want to cre

Is it possible to create jquery widget开发者_运维百科 include files that ONLY contain one specific widget? If I use the custom ui download builder then it insists on including the ui core. I want to create a load of individual widget files, plus a file just containing the core. That way, I can easily include the ui core plus each individual widget that I need for the site, and I can see at a glance which ui widgets are being used by a page, rather than having a single jquery-ui-custom.min.js file where it is not obvious which widgets are included within it.


$('head').append('<script src="http://example.com/widget.js"></script>');

or if you want to be really clever about it check if the file has been included first.

if( ! $('head script[src="http://example.com/widget.js"]').length ){

   $('head').append('<script src="http://example.com/widget.js"></script>');
}

which checks if the widget has NOT been loaded then add it otherwise it may conflict and give un-expected results :) .

0

精彩评论

暂无评论...
验证码 换一张
取 消