File: test.jsx compiles to bundle.js using Gulp and Browserify.
File: test.jsx:
var $ = require('jquery');
$("div#addTagModal").modal("hide");
In browser when I load the page I get this error:
Uncaught TypeError: undefined is not a function
On this line:
$("div#addTagModal").modal("hide");
I have no clue what is wrong. :/
$.ajax works fine so I assume that jQuery is loaded properly.
Bootstrap is included in html using a script tag and I have checked the ID of modal.
I have a button that once clicked opens that modal:
<button className="btn btn-success" data-toggle="modal" href="#addTagModal" type="button">
<i class="icon-plus"></i>
</button>
Any ideas?
This is my gulp task:
gulp.task('browserify', function() {
gulp.src('app/assets/js/main.js')
.pipe(browserify({
debug : true,
transform: ['reactify']
}))
.on('error', gutil.log)
.pipe(rename('public/js/bundle.js'))
.pipe(gulp.dest('./'))
});
And in main.js I have this code:
var app = require('./test.jsx');
modalis not a jQuery object's method, you have to include the relatedbootstrapscripts in your module. If you are using ascripttag for loading bootstrap, do it for jQuery lib too, as jQuery should be loaded before it's plugins.var Bootstrap = require('bootstrap')but it does not work.