问题描述
我想在Backbone.js应用程序中使用响应式 pickadate.js 日期选择器。
I would like to use the responsive pickadate.js date picker in my Backbone.js application.
我正在使用Browserify进行管理
I am using Browserify to manage modules and dependencies and wondering how to integrate pickadate.
我从 npm install 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)
我想我应该使用browserify-shim但是。 .. 怎么样? Pickadate不会导出任何内容。
I think I should use browserify-shim but.... how? Pickadate does not export anything.
更新
使用咕unt声进行除味(工程对于其他模块):
Using debowerify with grunt (works for other modules):
var pickadate = require('pickadate');
//...
render: function() {
//...
this.$el.find('.form-group input[name=dateEntry]').pickadate();
}
[错误] TypeError:'undefined'不是一个函数(评估'this 。$ el.find('。form-group input [name = dateEntry]')。pickadate()')(app.js,第18803行)
[Error] TypeError: 'undefined' is not a function (evaluating 'this.$el.find('.form-group input[name=dateEntry]').pickadate()') (app.js, line 18803)
推荐答案
我已经成功完成了以下步骤:
I have done the steps below successfully:
通过使用browserb进行debowerify,我可以执行以下操作:
Using debowerify with browserify, I can do like below:
require('jquery');
require('pickadate');
这篇关于使用Browserify要求pickadate.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!