給easyui datebox擴展一個清空的實例
步驟一:拓展插件
/** * 給時間框控件擴展一個清除的按鈕 */ $.fn.datebox.defaults.cleanText = '清空'; (function ($) { var buttons = $.extend([], $.fn.datebox.defaults.buttons); buttons.splice(1, 0, { text: function (target) { return $(target).datebox("options").cleanText }, handler: function (target) { $(target).datebox("setValue", ""); $(target).datebox("hidePanel"); } }); $.extend($.fn.datebox.defaults, { buttons: buttons }); })(jQuery);
步驟二:如果需要將清空按鈕漢化,在easyui-lang-zh_CN.js中添加如下代碼
if ($.fn.datebox){ $.fn.datebox.defaults.currentText = '今天'; $.fn.datebox.defaults.closeText = '關閉'; $.fn.datebox.defaults.cleanText = '清空'; $.fn.datebox.defaults.okText = '確定'; $.fn.datebox.defaults.missingMessage = '該輸入項為必輸項';
通過以上兩個步驟,就可以給easyui datebox時間框控件擴展一個清空按鈕了~~~
現在我們來看看做出來的效果圖: