mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
Prerequisites to the custom fields
SVN:trunk[3909]
This commit is contained in:
@@ -9,7 +9,9 @@ $(function()
|
|||||||
// default options
|
// default options
|
||||||
options:
|
options:
|
||||||
{
|
{
|
||||||
validators: null
|
validators: null,
|
||||||
|
validate_callback: 'validate', // When using an anonymous function, use the 'me' parameter to acces the current widget : function(me){ return me.validate(); },
|
||||||
|
get_current_value_callback: 'getCurrentValue'
|
||||||
},
|
},
|
||||||
|
|
||||||
// the constructor
|
// the constructor
|
||||||
@@ -25,12 +27,22 @@ $(function()
|
|||||||
me.options.validators = data;
|
me.options.validators = data;
|
||||||
});
|
});
|
||||||
this.element
|
this.element
|
||||||
.bind('validate', function(event, data){
|
.bind('validate get_current_value', function(event, data){
|
||||||
return me.validate();
|
var callback = me.options[event.type+'_callback'];
|
||||||
});
|
|
||||||
this.element
|
if(typeof callback === 'string')
|
||||||
.bind('get_current_value', function(event, data){
|
{
|
||||||
return me.getCurrentValue();
|
return me[callback]();
|
||||||
|
}
|
||||||
|
else if(typeof callback === 'function')
|
||||||
|
{
|
||||||
|
return callback(me);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
console.log('Form field : callback type must be a function or a existing function name of the widget');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
// called when created, and later when changing options
|
// called when created, and later when changing options
|
||||||
|
|||||||
@@ -295,9 +295,6 @@ $(function()
|
|||||||
{
|
{
|
||||||
this.buildData.style_code += ' '+ field.css_inline;
|
this.buildData.style_code += ' '+ field.css_inline;
|
||||||
}
|
}
|
||||||
// JS widget itop.form_field
|
|
||||||
var json_validators = (field.validators != undefined) ? JSON.stringify(field.validators) : 'null';
|
|
||||||
this.buildData.script_code += '; $("[' + this.options.field_identifier_attr + '=\'' + field.id + '\']").form_field({ validators: ' + json_validators + ' });';
|
|
||||||
|
|
||||||
},
|
},
|
||||||
buildForm: function()
|
buildForm: function()
|
||||||
|
|||||||
Reference in New Issue
Block a user