开发者

Backbonejs and including jQueryUI components

i was asking how to integrate jquery ui components inside backbonejs. and also other jquery libraries li开发者_JAVA技巧ke 'chosen'.

as i add for example the datepicker as default and its not working, in a rendered view from backbone.

how to integerate jqueryui in backbonejs.

thanks for the provided comments.

based on the below comments, i add the jqueryui components code to backbone.js view and its working fine now also the timepicker addon. the library based on jquery "chosen http://harvesthq.github.com/chosen/" which still didn't work with backbone.js views.


I use a trigger at the end of the render method to fire the jqueryui methods. Something like this perhaps.

initialize: function () {
    this.on('postRender', this.postRender, this);
}

render: function () {
    this.setElement(document.createElement('div'));
    this.$el.text('click me');
    $('body').append(this.$el);
    this.trigger('postRender');
}

postRender: function() {
    this.$el.button();
}

You can trigger 'postRender' when you know that the element is has been added to the dom and is visible, you shouldn't have any problems using it in this way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜