very nice :)
I am wondering if you have / will support building select fields
dynamically(runtime) from ajax?
I am in the process of bolting something on the 0.1 one..
usage something like this:
new inputEx.Form( {
fields: [
{label: 'Title', type: 'select'
, inputParams: {
name: 'title',
selectJSON: "/AJAJ_db-update.php?
ajaxObj=dropdown&ajaxAction=populate&"+"mTable=basecode&mField=basetype&mValue=DGR&rValue=BaseRecID&rText=LabelText"
},
},
{label: 'Firstname', inputParams: {name: 'firstname', required:
true, value:'Jacques' } },
{label: 'Lastname', inputParams: {name: 'lastname',
value:'Dupont' } }
],
Field.js:
inputEx.SelectField.prototype.AJAXpopulateJSON= function()
{
if (YAHOO.lang.isString(this.options.selectJSON)) {
var url = this.options.selectJSON;
var ds = new YAHOO.util.DataSource(url);
ds.responseType = YAHOO.util.DataSource.TYPE_JSON;
ds.responseSchema = {
fields: ['value', 'text'],
resultsList: 'data'
};
ds.connMethodPost = true;
ds.sendRequest(''
,function(sRequest, oResponse) {
this.options.selectJSON = oResponse.results;
this.fireUpdatedEvt();
//this.renderComponent;
//need to redraw the element when the data becomes available.
// ??
}
,this
);
}
}
inputEx.SelectField.prototype.renderComponent = function() {
this.el = inputEx.cn('select', {name:
this.options.name || ''});
if (this.options.selectJSON)
{ if (YAHOO.lang.isString(this.options.selectJSON) )
{this.AJAXpopulateJSON(this.options.selectJSON,this);}
this.options.selectValues=[];this.options.selectOptions=[];
for (var i=0 ; i < this.options.selectJSON.length; i++ )
{
this.options.selectValues[i] = this.options.selectJSON[i].value;
this.options.selectOptions[i] = this.options.selectJSON[i].text;
}
}
...
Sorry if this is already hiding in there somewhere..
The problem that I am facing is that the ajax doesnt get back untill
the field is rendered, and I dont see a way to re-render it?
Any assistance will be greatly appreciated