Jeditable with jQuery UI Datepicker

前端 未结 5 769
借酒劲吻你
借酒劲吻你 2020-12-31 15:50

I need to have a click to edit element on a page, that will in turn invoke an instance of the jQuery UI Datepicker.

Currently, I\'m using JEditable to provide the i

5条回答
  •  醉梦人生
    2020-12-31 16:28

    Here is my solution. I use custom date format and on datepicker close, I reset the input form and apply cssdecoration (my jeditable improvement). Working with jQuery UI 1.5.2

    $.editable.addInputType('datepicker', {
    element : function(settings, original) {
        var input = $('');
        if (settings.width  != 'none') { input.width(settings.width);  }
        if (settings.height != 'none') { input.height(settings.height); }
        input.attr('autocomplete','off');
        $(this).append(input);
        return(input);
    },
    plugin : function(settings, original) {
        /* Workaround for missing parentNode in IE */
        var form = this;
        settings.onblur = 'ignore';
        $(this).find('input').datepicker({
            firstDay: 1,
            dateFormat: 'dd/mm/yy',
            closeText: 'X',
            onSelect: function(dateText) { $(this).hide(); $(form).trigger("submit"); },
            onClose: function(dateText) {
                original.reset.apply(form, [settings, original]);
                $(original).addClass( settings.cssdecoration );
                },
        });
    }});
    

提交回复
热议问题