[英]jQuery UI with Ember CLI
So I'm pretty much having the exact problem listed here: Using jquery in Ember-cli 因此,我几乎在这里列出了确切的问题: 在Ember-cli中使用jquery
But I've already done the following as recommended in the thread above: 但是我已经按照上面的线程中的建议进行了以下操作:
Added: 添加:
app.import('bower_components/jquery-ui/jquery-ui.js');
app.import('bower_components/jquery-ui/ui/tooltip.js');
Changed 已变更
Ember.$(selector).tooltip();
to 至
this.$(selector).tooltip();
Ember isn't recognizing the tooltip function as being defined despite UI being installed and doing the above. 尽管安装了UI并进行了上述操作,Ember仍无法将工具提示功能定义为已定义。
Error: 错误:
Uncaught TypeError: undefined is not a function
未捕获的TypeError:undefined不是函数
Any help? 有什么帮助吗?
A few things. 一些东西。 First,
jquery-ui.js
is the entire jQuery UI library. 首先,
jquery-ui.js
是整个jQuery UI库。 So, you've already got tooltip
in there. 因此,您已经有了
tooltip
。 Remove that second line. 删除第二行。
If you only want the tooltip, you'll need to import core
, widget
and position
separately ( reference ), and then the tooltip
. 如果只需要工具提示,则需要分别导入
core
, widget
和position
( 参考 ),然后导入tooltip
。
Finally, you probably want to include a theme. 最后,您可能想包含一个主题。 The default one lives here:
默认值位于此处:
app.import('bower_components/jquery-ui/themes/smoothness/jquery-ui.min.css');
With that, stick the this.$().tooltip()
in your view's didInsertElement
callback and you should be good to go. 这样,将
this.$().tooltip()
didInsertElement
在视图的didInsertElement
回调中,您应该会很好。
The problem was I had imported Ember Data which was causing an error (apparently it's imported by default or the options were stated incorrectly). 问题是我导入了Ember Data,这导致了错误(显然它是默认导入的,或者选项说明不正确)。 Once I removed that, UI is now working properly.
一旦我删除了它,UI现在可以正常工作。
Thank you for all your help Sam! 谢谢您对Sam的帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.