简体   繁体   English

EmberJS将数据传递到jQuery插件

[英]EmberJS passing data to jQuery plugin

Can people please tell me the best way to pass an ember model to a jQuery plugin. 人们能否告诉我将余烬模型传递给j​​Query插件的最佳方法。

I would normally instantiate a jQuery model in the onDidInsert() function, but if my jQuery module needs to be passed dynamic model data then what is the best way of doing this? 我通常会在onDidInsert()函数中实例化jQuery模型,但是如果我的jQuery模块需要传递动态模型数据,那么执行此操作的最佳方法是什么?

Thanks. 谢谢。

If your view is for a route then you can access the controller and therefore your model. 如果您要查看路线,则可以访问控制器 ,从而可以访问模型。

// onDidInsert()
this.get('controller.model');

Else you'll first have to pass your model to the view, wherever you instance the view. 否则,无论您在何处实例化视图,都必须首先将模型传递给视图。 At that point you'll get() it directly from the view. 届时,您将直接从视图中get()

<!-- *.hbs -->
{{view App.SomeView someName=this.model}}

// onDidInsert()
this.get('someName');

Of course there are different contexts when using a view but this should give you the general idea. 当然,使用视图时会有不同的上下文,但这应该可以为您提供总体思路。 If not, let me know how you are using the view. 如果没有,请告诉我您如何使用视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM