I've looked at all the info (ok.. first google page hits) related to this issue but the solutions didn't work.
my config.js looks like below:
var config = {
paths : {
jquery : "//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min",
// "jquery" : "momsplanner/backgrid/assets/js/jquery",
"underscore" : "momsplanner/underscore/underscore",
"text" : "momsplanner/requirejs_text/text",
// "backbone" : "momsplanner/backbone",
"Backbone" : "momsplanner/backgird/assets/js/backbone",
"Backgrid" : "momsplanner/backgrid/lib/backgrid",
"bootstrap" : "momsplanner/bootstrap/dist/js/bootstrap"
// "bootstrap" : "//netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap"
// 'jquery.bootstrap' : "momsplanner/backgrid/assets/js/bootstrap"
},
// A lot of dependencies don't support AMD loaders. Here is an example shim
// configuration to remedy that.
shim : {
"underscore": {
exports: '_'
},
"Backbone" : {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
"Backgrid" : {
deps: ['jquery', 'underscore', 'backbone'],
exports: 'Backgrid'
},
'bootstrap' : {
deps: ["jquery"]
}
}
};
if (typeof exports === 'object') {
// If this file is loaded from node, export the config variable.
module.exports = config;
} else if (typeof define === 'function' && define.amd) {
// If this file is being loaded in the browser, load the config
define([], function() {
requirejs.config(config);
});
}
And I'm loading a module like following
require( [
'momsplanner/js/custom_bootstrap'
], function(custom_bootstrap) {
$(document).ready(function() {
custom_bootstrap.setNavbarActive();
custom_bootstrap.gotoTab();
});
});
custom_bootstrap looks like:
define([
"jquery",
"bootstrap"
], function($) {
.. omitting some functions..
// http://stackoverflow.com/questions/7862233/twitter-bootstrap-tabs-go-to-specific-tab-on-page-reload
function gotoTab() {
// Javascript to enable link to tab
var hash = document.location.hash;
var prefix = "tab_";
if (hash) {
var $selector = $('.nav-tabs a[href='+hash.replace(prefix,"")+']');
console.log($selector.html());
$selector.tab('show'); // ERROR HERE!!!! <------------------------
}
// Change hash for page-reload
$('.nav-tabs a').on('shown', function (e) {
window.location.hash = e.target.hash.replace("#", "#" + prefix);
});
}
return {
setNavbarActive: setNavbarActive,
gotoTab: gotoTab
};
I get error message at the $selector.tab('show') with error message:
Uncaught TypeError: Object [object Object] has no method 'tab'
How do I fix this error?