Requiring pickadate.js with Browserify

拜拜、爱过 提交于 2020-01-16 03:39:09

问题


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)


回答1:


I have done the steps below successfully:

Using debowerify with browserify, I can do like below:

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


来源:https://stackoverflow.com/questions/25888292/requiring-pickadate-js-with-browserify

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!