how and where to initialize jquery datatable in backbone view

霸气de小男生 提交于 2019-12-04 11:27:29

Most likely, the jQuery plugin needs the elements to be on the page to work. You don't show where you are calling render on that view, but I am going to assume you are doing something like this:

var view = new PlayerView();
$('#foo').html(view.render().el);  // this renders, then adds to page

If this is true, then using the plugin inside render is too early, since the view's html is not yet added to the page.

You can try this:

var view = new PlayerView();
$('#foo').html(view.el);   // add the view to page before rendering
view.render();

Or you can try this:

var view = new PlayerView();
$('#foo').html(view.render().el);
view.setupDataTable();    // setup the jQuery plugin after rendering and adding to page
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!