0
錯誤:TypeError:$(...)。selectpicker不是函數第一次打開Web應用程序時發生的錯誤。
在我app.js
requirejs.config({ baseUrl: '', paths: { "jquery": "js/jquery", "jquery-ui": "js/jquery-ui", text: "lib/text", //"css": "css", handlebars: 'js/handlebars', moment: "js/moment.min", bootstrap: 'js/bootstrap.min', somtjquery: 'widgets/somt/js/somtjquery', bootstrapselect: 'js/bootstrap-select', utils: 'widgets/somt/js/utils', filterwidget: 'widgets/somt/js/filterwidget' }, shim: { handlebars: { exports: 'Handlebars' }, 'bootstrap': { deps: ['jquery'] }, //'bootstrapdatepicker':{deps: ['jquery','bootstrap']}, 'somtjquery': { deps: ['jquery', 'utils', 'bootstrap'] }, 'bootstrapselect': { deps: ['jquery', 'bootstrap'] }, 'jquery': { exports: '$' }, "datepicker": { deps: ["jquery-ui", "bootstrap"], exports: "$.fn.datepicker" }, 'tooltip': { deps: ['jquery'], exports: '$.fn.tooltip' }, 'filterwidget': { deps: ['jquery', "jquery-ui", "bootstrap", "bootstrapselect"], exports: 'filterwidget' } } }); In filterwidget.js define(["handlebars",'hbs!widgets/somt/templates/pfilter'],function(Handlebars,filter){ var selector = "#somt-filter-area"; $(selector).html(filter); $(function selectDatePicker() { try { $(selector).find('.selectpicker').selectpicker(); } catch (e) { console.log("Date select err message : " + e); } try { $(selector).find("#week").datepicker({ showOn: "button", buttonImage: "images/common-calendar-month-glyph.svg", buttonImageOnly: true, firstDay: 1, beforeShowDay: function(date) { return [date.getDay() === weekofday, ""]; }, dayNamesMin: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], maxDate: currentcutoffday, dateFormat: 'mm/dd/yy' }); } catch (e) { console.log("Date picker err message : " + e); } }); });
特別是我在Firefox 36及以下版本