Javascript 如何使Jquery插件与emberJS一起工作?
我正在尝试使用Jquery在我的页面上生成响应文本。在我设置ember之前,一切正常,现在插件停止运行 插件的Javascript:Javascript 如何使Jquery插件与emberJS一起工作?,javascript,jquery,ember.js,jquery-plugins,Javascript,Jquery,Ember.js,Jquery Plugins,我正在尝试使用Jquery在我的页面上生成响应文本。在我设置ember之前,一切正常,现在插件停止运行 插件的Javascript: <script> $('p').flowtype({ fontRatio: 10 }); $('h1').flowtype({ minFont: 40, maxFont: 140, fontRatio: 6 }); </script> 经过一
<script>
$('p').flowtype({
fontRatio: 10
});
$('h1').flowtype({
minFont: 40,
maxFont: 140,
fontRatio: 6
});
</script>
经过一些研究,我发现您需要在ember js代码中封装插件,但我不知道如何做到这一点。感谢您的帮助 渲染视图后,需要运行JQuery。您可以使用
didInsertElement
执行此操作
App.ApplicationView = Ember.View.extend({
didInsertElement: function () {
this._super();
this.$('p').flowtype({
fontRatio: 10
});
this.$('h1').flowtype({
minFont: 40,
maxFont: 140,
fontRatio: 6
});
}
})
var App = Ember.Application.create({
LOG_TRANSITIONS: true
});
App.Router.map(function () {
this.route('about');
})
App.ApplicationView = Ember.View.extend({
didInsertElement: function () {
this._super();
this.$('p').flowtype({
fontRatio: 10
});
this.$('h1').flowtype({
minFont: 40,
maxFont: 140,
fontRatio: 6
});
}
})