【问题标题】:jQuery UI and Closure Compiler Advanced OptimizationsjQuery UI 和 Closure 编译器高级优化
【发布时间】:2014-11-22 10:27:12
【问题描述】:
我正在尝试在我的项目中使用具有高级优化功能的 Closure Compiler,我正在使用 jQuery 1.11.1 和 jQuery UI 1.10.4。
作为 jQuery 的 extern,我发现了一个 jQuery 1.9 的 extern,我认为它可以正常工作,但是我遇到了 jQuery UI 的问题,我无法找到任何版本的任何 extern。
任何人都知道 jQuery UI 的任何外部人员吗?
谢谢。
PS:我尝试使用网页 http://www.dotnetwise.com/Code/Externs/,但生成的 extern 没有帮助:-/
【问题讨论】:
标签:
javascript
jquery
jquery-ui
google-closure-compiler
【解决方案1】:
我很幸运地创建了自己的简单外部文件。例如,如果我只使用 .draggable 和 .resizable,这就是它包含的内容:
jQuery.prototype.resizable = function (arg1, arg2, arg3) { };
$.prototype.resizable = function (arg1, arg2, arg3) { };
jQuery.prototype.draggable = function (arg1, arg2, arg3) { };
$.prototype.draggable = function (arg1, arg2, arg3) { };
然后在我的 .js 文件中,在初始化时使用带引号的字符串而不是点表示法来表示属性名称:
// USE THIS:
$(".draggable").draggable({ "axis":"x", "containment": "parent",
"cursor":"move", "handle":".dragHandle", "snap":"#banner, .draggable", "snapMode":"outer"
});
//INSTEAD OF THIS:
$(".draggable").draggable({ axis:"x", containment: "parent",
cursor:"move", handle:".dragHandle", snap:"#banner, .draggable", snapMode:"outer"
});