解决:seajs无法封装jQuery模板插件jTemplates

63 views
Skip to first unread message

贺天卓

unread,
Oct 15, 2012, 8:31:53 AM10/15/12
to se...@googlegroups.com
一直在用一款jQuery插件,现在着手把所有代码都用SeaJS封装后,发现其他jq插件都能正常工作,唯独jTemplates不行。

http://jtemplates.tpython.com


调用代码为:
var $ = require('jquery');
require('jtemplates/jquery-jtemplates.seajs')($);

但在$对象下都没有jTemplates对象。

最后找到问题原因了。


jTemplates在返回jQuery对象前增加了一个判断语句

if (window.jQuery && !window.jQuery.createTemplate) {  代码段  };



解决办法:用未压缩代码删除判断语句后压缩,搞定。

Frank Wang

unread,
Oct 15, 2012, 8:33:43 AM10/15/12
to se...@googlegroups.com
感谢分享,挺好的经验沉淀,感谢。

2012/10/15 贺天卓 <hetia...@gmail.com>



--
王保平 / 玉伯(射雕)
送人玫瑰手有余香

lcat

unread,
Apr 3, 2013, 3:55:48 AM4/3/13
to se...@googlegroups.com
有没有jquery插件封装的demo打包一份给我看下,为什么我试了几个都不行。4048...@qq.com谢谢哈

在 2012年10月15日星期一UTC+8下午8时31分54秒,贺天卓写道:

Frank Wang

unread,
Apr 7, 2013, 4:07:39 AM4/7/13
to seajs
对的,就是把

if (window.jQuery && !window.jQuery.createTemplate) {  代码段  };
把 if 去掉就好。因为这个 if,导致在 CMD 环境下,始终为 false,进不去。



2013/4/3 lcat <lx404...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "seajs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to seajs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
0 new messages