jquery - DataTables not initializing, using RequireJS/Backbone -
i've worked require , datatables before first time setting things up. i've stripped away of sensitive files being called in code below think need out.
i have seen mixed messages on whether min js path needs added or if need both. because there aren't errors present seems bring called. in addition, i've heard mixed messages needing shim datatables. seem right? have standard table in handlebars file populated json file. let me know if need shown well.
first section of code require.config file, last chunk view handlebars file.
requirejs.config({ // baseurl: "js", paths: { backbone: "bower_components/backbone/backbone", jquery: "bower_components/jquery/dist/jquery", jquerybridget: "bower_components/jquery-bridget/jquery.bridget", jqueryui: "bower_components/jquery-ui/jquery-ui", modernizr: "bower_components/modernizr/modernizr", datatables: "bower_components/datatables/media/js/jquery.datatables.min" }, shim: { underscore: { exports: "_" }, jquery: { exports: "$" }, modernizr: { exports: "modernizr" }, backbone: { deps: ["jquery", "underscore"], exports: "backbone" } } }); define(["marionette", "hbs!apps/project/templates/components/project-funds/project-funds-performancetable", "datatables"], function (marionette, projectfundsperformancetabletemplate, datatables) { var projectfundsperformancetableview = marionette.itemview.extend({ template: projectfundsperformancetabletemplate, initialize: function () { this.deferred = this.model.fetch({ reset: true, // datatype: "jsonp", success: (function () { // alert(' service request success: '); }), error: (function (e) { // alert(' service request failure: ' + e); }), complete: (function (e) { // alert(' service request completed ' + e); }) }); this.model.on("reset", this.render); }, onshow: function(){ $('#ce--funds--performancetable').datatable(); } }); return projectfundsperformancetableview; });
if using recent versions of jquery, backbone , underscore, not need shims.
jquery has not needed shim since time before 1.9.
check annotated source of backbone , underscore. search "amd" in both sources , you'll see detect amd loader , call define when amd loader present, no shims.
using shim not needed can lead undefined behavior , can explain problem experiencing.
oh, , datatables not need shim either if using relatively recent version. use 1.10.2 without shim.
Comments
Post a Comment