最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Jquery timepicker addon not working correctly - Stack Overflow

programmeradmin6浏览0评论

I have this code in my view (JS):

$("#mydivelement").timepicker();

Instead of only timepicker, it displays datetimepicker. I have datepicker defaults set in Layout page if it matters:

$.datepicker.setDefaults({
        dateFormat: 'dd/mm/yy',
        yearRange: '1930:2012',
        changeYear: true,
        changeMonth: true,
        autoSize: true,
        showAnim: 'slideDown',
        firstDay: 1
    });

Update: Used Library- jquery-ui-timepicker-addon.js

I have this code in my view (JS):

$("#mydivelement").timepicker();

Instead of only timepicker, it displays datetimepicker. I have datepicker defaults set in Layout page if it matters:

$.datepicker.setDefaults({
        dateFormat: 'dd/mm/yy',
        yearRange: '1930:2012',
        changeYear: true,
        changeMonth: true,
        autoSize: true,
        showAnim: 'slideDown',
        firstDay: 1
    });

Update: Used Library- jquery-ui-timepicker-addon.js

Share Improve this question edited Jun 6, 2012 at 13:06 karaxuna asked Jun 6, 2012 at 12:35 karaxunakaraxuna 26.9k13 gold badges86 silver badges119 bronze badges 5
  • just an idea: why do you set dateFormat when you want a timepicker... perhaps that could be the problem. – evotopid Commented Jun 6, 2012 at 12:38
  • It's datepicker defaults, not timepicker – karaxuna Commented Jun 6, 2012 at 12:39
  • Oh... sorry, I just didn't read exactly... (now it makes sense) :D – evotopid Commented Jun 6, 2012 at 12:41
  • What timepicker library are you using? – Ayman Safadi Commented Jun 6, 2012 at 13:04
  • jquery-ui-timepicker-addon.js – karaxuna Commented Jun 6, 2012 at 13:05
Add a ment  | 

1 Answer 1

Reset to default 5

You are missing to add {} to inside of .timepicker()

Jquery

$(function() {
    $( "#mydivelement" ).datepicker({
     dateFormat: 'dd/mm/yy',
        yearRange: '1930:2012',
        changeYear: true,
        changeMonth: true,
        autoSize: true,
        showAnim: 'slideDown',
        firstDay: 1
    });
    $('#timepicker').timepicker({}); // it shows only timepicker without datepicker
});

jsFiddle example

发布评论

评论列表(0)

  1. 暂无评论