Search code examples
javascriptbrowserifybrowserify-shimpickadate

Requiring pickadate.js with Browserify


I would like to use the responsive pickadate.js date picker in my Backbone.js application.

I am using Browserify to manage modules and dependencies and wondering how to integrate pickadate.

I started with a npm install pickadate which added the node module to my project.

Then, in one of my views, I try this:

var pickadate = require('pickadate');
this.$el.find('input[name=dateEntry]').pickadate();

The error is on the second line which throws this error:

[Error] TypeError: 'undefined' is not a function (evaluating 'this.$el.find('input[name=dateEntry]').pickadate()') (app.js, line 16654)

I think I should use browserify-shim but.... how? Pickadate does not export anything.

UPDATE

Using debowerify with grunt (works for other modules):

var pickadate = require('pickadate');

//... 

render: function() {

//...

this.$el.find('.form-group input[name=dateEntry]').pickadate();
}

[Error] TypeError: 'undefined' is not a function (evaluating 'this.$el.find('.form-group input[name=dateEntry]').pickadate()') (app.js, line 18803)


Solution

  • I have done the steps below successfully:

    Using debowerify with browserify, I can do like below:

    require('jquery');
    require('pickadate');