【问题标题】:Bootstrap Datetimepicker and X-editable - parse errorBootstrap Datetimepicker 和 X-editable - 解析错误
【发布时间】:2015-11-26 14:56:40
【问题描述】:

我试图找到解决方案,但没有成功。

我正在尝试使用“日期时间”类型运行 X-editable 来为用户提供日期时间选择器。 Bootstrap DateTimePicker 与同一页面上的其他元素配合良好,因此 DTP 没有问题。

尽管选择了 'data-*' 的方式或通过 JS 推送所有内容,但我总是遇到错误

Uncaught TypeError: Cannot read property 'parseFormat' of undefineda.extend.initPicker 
@ bootstrap-editable.min.js:7b 
@ bootstrap-editable.min.js:7a.fn.editableutils.createInput 
@ bootstrap-editable.min.js:5b.init 
@ bootstrap-editable.min.js:5b 
@ bootstrap-editable.min.js:5(anonymous function) 
@ bootstrap-editable.min.js:5n.extend.each 
@ jquery.js:374n.fn.n.each 
@ jquery.js:139a.fn.editable 
@ bootstrap-editable.min.js:5(anonymous function) 
@ panel:1016j 
@ jquery.js:3099k.fireWith 
@ jquery.js:3211n.extend.ready 
@ jquery.js:3417I @ jquery.js:3433

当我从 min 更改为普通 JS 时,我跟踪到:

this.parsedFormat = this.dpg.parseFormat(this.options.format, this.options.formatType);

我不知道如何解决它。 我什至从 x-editable docs 复制了整个示例,因为我担心它是拼写错误,但事实并非如此。

有什么想法吗?

【问题讨论】:

    标签: jquery twitter-bootstrap datetimepicker x-editable bootstrap-datetimepicker


    【解决方案1】:

    看起来像 x-editable 中的错误。查看他们的源代码,datetimepicker 的设置有

    //store DPglobal
    this.dpg = $.fn.datetimepicker.DPGlobal; 
    
    //store parsed formats
    this.parsedFormat = this.dpg.parseFormat(this.options.format, this.options.formatType);
    

    但 datetimepicker 插件实际上没有 DPGlobal 属性,因此 this.dpg 未定义。

    但是,日期选择器设置有类似的代码可以工作

    //store DPglobal
    this.dpg = $.fn.bdatepicker.DPGlobal; 
    
    //store parsed formats
    this.parsedFormat = this.dpg.parseFormat(this.options.format);
    

    因为 DPGlobal 实际上是在 datepicker 插件源中设置的

    日期时间选择器的设置应该使用$.fn.bdatepicker.DPGlobal 而不是$.fn.datetimepicker.DPGlobal

    【讨论】:

    • 有没有人解决这个问题?我也有同样的问题。
    • bootstrap-editable.js 中,查找this.dpg = $.fn.datetimepicker.DPGlobal; 并将其更改为this.dpg = $.fn.bdatepicker.DPGlobal;
    猜你喜欢
    • 1970-01-01
    • 2018-04-06
    • 1970-01-01
    • 2021-11-05
    • 1970-01-01
    • 2018-01-15
    • 2015-12-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多