Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery EasyUI Form Plugin - Datebox

jQuery EasyUI Form Plugin - Datebox


jQuery EasyUI Plugins jQuery EasyUI Plugins


Extends $.fn.combo.defaults. Override the default defaults via $.fn.datebox.defaults.

The datebox combines an editable text box with a drop-down calendar panel from which users can select a date. A string entered in the text box can be converted into a valid date. The selected date can also be converted into a desired format.

Depends on

Usage

Create a datebox from markup.





Create a datebox using JavaScript.







$('#dd').datebox({

    required:true

});

property

This property extends from the combo; the following are properties added for the datebox.

Name Type Description Default value
panelWidth number The width of the drop-down calendar panel. 180
panelHeight number The height of the drop-down calendar panel. auto
currentText string The text displayed on the Current Date button. Today
closeText string The text displayed on the Close button. Close
okText string The text displayed on the OK button. Ok
disabled boolean Disables the field when set to true. false
buttons array The buttons below the calendar. Available since version 1.3.5.
 代码实例:     

var buttons = $.extend([], $.fn.datebox.defaults.buttons); buttons.splice(1, 0, { text: 'MyBtn', handler: function(target){ alert('click MyBtn'); } }); $('#dd').datebox({ buttons: buttons });| onSelect | event| onSelect | event | sharedCalendar | string,selector | A shared calendar used by multiple date box (datebox) components. This property is available since version 1.3.5.
Code example:





| null| onSelect | event | formatter | function | A function that formats a date. It has a 'date' parameter and returns a string value. The following example demonstrates how to override the default formatter function.
$.fn.datebox.defaults.formatter = function(date){

    var y = date.getFullYear();

    var m = date.getMonth()+1;

    var d = date.getDate();

    return m+'/'+d+'/'+y;

}

|| onSelect | event | parser | function | A function that parses a date string. It takes a 'date' string and returns a date value. The following example demonstrates how to override the default parser function.
$.fn.datebox.defaults.parser = function(s){

    var t = Date.parse(s);

    if (!isNaN(t)){

        return new Date(t);

    } else {

        return new Date();

    }

}

| onSelect | event |

Events

Name Parameters Description
onSelect date Triggered when the user selects a date.
 代码实例:     

$('#dd').datebox({     onSelect: function(date){         alert(date.getFullYear()+":"+(date.getMonth()+1)+":"+date.getDate());     } }); |

Method

This method extends from Combo (combo), below are the methods overridden for the date box (datebox).

Name Parameters Description
options none Returns the options object.
calendar none Gets the calendar object. The following example demonstrates how to get the calendar object and then display it again.

// get the calendar object var c = $('#dd').datebox('calendar'); // set the first day of week to monday c.calendar({ firstDay: 1 });| onSelect | event | setValue | value | Sets the value of the datebox.
Code example:

$('#dd').datebox('setValue', '6/1/2012');    // set datebox value

var v = $('#dd').datebox('getValue');    // get datebox value

|


jQuery EasyUI Plugins jQuery EasyUI Plugins