r2413 - Added checks for removing a mask without destroying the instance.
Author: powella
Date: Mon Mar 30 09:15:08 2009
New Revision: 2413
Modified:
branches/dev/mask/ui/ui.mask.js
Log:
Added checks for removing a mask without destroying the instance.
Added check for changing the placeholder to an empty string.
Modified: branches/dev/mask/ui/ui.mask.js
==============================================================================
--- branches/dev/mask/ui/ui.mask.js (original)
+++ branches/dev/mask/ui/ui.mask.js Mon Mar 30 09:15:08 2009
@@ -24,8 +24,10 @@
$.extend(this, { caret: function(begin, end){ return
$.ui.mask.caret(self.element, begin, end); } });
- if(!options.mask || !options.mask.length) return; //no mask pattern
defined. no point in continuing.
- if(!options.placeholder || !options.placeholder.length)
options.placeholder = '_'; //in case the user decided to nix a placeholder.
+ if(!options.mask || !options.mask.length){ return; } //no mask pattern
defined. no point in continuing.
+ if(!options.placeholder || !options.placeholder.length){
+ options.placeholder = '_'; //in case the user decided to nix a
placeholder.
+ }
this._prepareBuffer();
this._bindEvents();
@@ -59,10 +61,19 @@
_setData: function(key, value) {
$.widget.prototype._setData.apply(this, arguments);
+ var options = this.options;
switch (key) {
case 'mask':
+ //no mask pattern defined. no point in continuing.
+ if(!options.mask || !options.mask.length){
+ this.element.unbind('.mask')
+ break;
+ }
case 'placeholder':
+ if(!options.placeholder || !options.placeholder.length){
+ options.placeholder = '_'; //in case the user decided to nix a
placeholder.
+ }
this.element.val('');
this._prepareBuffer();
!this.eventsBound && this._bindEvents();