Hybrid View
-
30 Sep 2010 6:07 AM #1
Newbie: help with factory function
Newbie: help with factory function
Hi everyone,
Im working on this factory function and I have no idea what im doing wrong. Im getting this error from the chrome console "Uncaught SyntaxError: Unexpected token (" and I also put the JSON code into JSONlint and got this error message "syntax error, unexpected TINVALID at line 1
Parsing failed"
any insight is appreciatedCode:Ext.ns('Ext.ux'); //start of factory function Ext.ux.CarterRemoteCombo = function(config) { return new Ext.ux.form.ComboBoxAdd(Ext.apply({ name: 'SiteID', fieldLabel: this.name, hiddenName: this.name, displayField: 'lookupname', originalwhere: 'this.name', valueField: 'lookupid', moegalReturnid: 'this.valueField', comboVarname: 'tblbillboard_siteID', allowBlank: false, forceSelection: true, //pageSize:50, listWidth: 300, triggerAction: 'all', typeAhead:true, minChars: 3, //mode: 'remote', defaults at remote lazyInit: false, //hideTrigger1: false, combo defaults at false //hideTrigger2: false, clear defaults at false hideTrigger3: true, //search //hideTrigger4: false, add defaults at false listeners: { collapse: function(combo) { if(this.startValue != this.getValue()){ UpdateDependentComboboxStore('this.comboVarname',this.getValue(),'this.name',5,'this.mode'); console.log(this.name); console.log(this.getValue()); } add: function(this) { loadwindow('Add Site','includes/table-insert.asp',true,'tableID=5&refreshType=combo&refreshID=tblbillboard_siteID',false); }, lookup: function() { loadwindow('Search Site','includes/table-search.asp',true,'tableID=5&refreshType=combo&refreshID=tblbillboard_siteID&linktableID=&linkID='+this.store.baseParams.LinkID,true); }, render: function(this) { this.store.add(new Ext.data.Record({this.valueField:'40', this.displayField:'4000/4001CPA', linkedid:''})); this.setValue(40); UpdateDependentComboboxStore('this.comvoVarname',40,'this.name',5,'this.mode'); } } store: new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: 'includes/get-comboremote.asp', method: 'post' }), totalProperty: 'RecordCount', autoLoad: false, baseParams: {linkedid: "", allowNew: "true", allowSearch: "false", table: "tblsite", idname: "this.name", displayfield: "sitename", linkTableID: "", orderby: "this.name asc", where: "this.name", lookupID: 40}, fields:['this.valueField', 'this.displayField', 'linkedid'], id: 'this.valueField', root: 'Records', listeners: { load: function() { if (this.startValue != ''){ if(this.store.find('this.valueField',this.startValue) != '-1'){ this.setValue(this.startValue); UpdateDependentComboboxStore('this.comboVarname',this.getValue(),'this.name',5,'this.mode'); } } } } }) }, }, config)); }; Ext.reg('carterremotecombo', Ext.ux.CarterRemoteCombo);
thanks,
GamerDanger Zone!
-
30 Sep 2010 6:27 AM #2
I think these are probably scope issues. I tried the other factory function im working on and got the same JSONlint message. In the console I got "Uncaught SyntaxError: Unexpected token this".
this is the filler code I was given to test against. not sure if thats gonna make it any easier to answer the question.Code:Ext.ux.CarterRemoteCombo = function(config) { return new Ext.form.ComboBox(Ext.apply({ id: 'mycombo', fieldLabel: 'Locations', displayField: 'name', name: 'list_ids', mode: 'local', triggerAction: 'all', store: new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: 'list.asp', method: 'post' }), autoLoad: true, baseParams: config.baseParams || {Field1: '1', Field2: '2', Field3: '3'}, fields: [{name: 'id'}, {name: 'name'}], id: 'id', root: 'Records' }) }, config)); }; Ext.reg('carterremotecombo', Ext.ux.CarterRemoteCombo);Danger Zone!
-
30 Sep 2010 6:45 AM #3
Well just looking at the code in your first post there are syntax issues. Particularly in the "listeners" area between the "collapse" and "add" configs. There is no proper closure. And yes there at glance appears that there might be scoping issues. However I at least fixed the closure problems.
Code:Ext.ns('Ext.ux'); //start of factory function Ext.ux.CarterRemoteCombo = function (config) { return new Ext.ux.form.ComboBoxAdd(Ext.apply({ name: 'SiteID', fieldLabel: this.name, hiddenName: this.name, displayField: 'lookupname', originalwhere: 'this.name', valueField: 'lookupid', moegalReturnid: 'this.valueField', comboVarname: 'tblbillboard_siteID', allowBlank: false, forceSelection: true, //pageSize:50, listWidth: 300, triggerAction: 'all', typeAhead: true, minChars: 3, //mode: 'remote', defaults at remote lazyInit: false, //hideTrigger1: false, combo defaults at false //hideTrigger2: false, clear defaults at false hideTrigger3: true, //search //hideTrigger4: false, add defaults at false listeners: { collapse: function (combo) { if (this.startValue != this.getValue()) { UpdateDependentComboboxStore('this.comboVarname', this.getValue(), 'this.name', 5, 'this.mode'); console.log(this.name); console.log(this.getValue()); } }, add: function (this) { loadwindow('Add Site', 'includes/table-insert.asp', true, 'tableID=5&refreshType=combo&refreshID=tblbillboard_siteID', false); }, lookup: function () { loadwindow('Search Site', 'includes/table-search.asp', true, 'tableID=5&refreshType=combo&refreshID=tblbillboard_siteID&linktableID=&linkID=' + this.store.baseParams.LinkID, true); }, render: function (this) { this.store.add(new Ext.data.Record({ this.valueField: '40', this.displayField: '4000/4001CPA', linkedid: '' })); this.setValue(40); UpdateDependentComboboxStore('this.comvoVarname', 40, 'this.name', 5, 'this.mode'); } }, store: new Ext.data.JsonStore({ proxy: new Ext.data.HttpProxy({ url: 'includes/get-comboremote.asp', method: 'post' }), totalProperty: 'RecordCount', autoLoad: false, baseParams: { linkedid: "", allowNew: "true", allowSearch: "false", table: "tblsite", idname: "this.name", displayfield: "sitename", linkTableID: "", orderby: "this.name asc", where: "this.name", lookupID: 40 }, fields: ['this.valueField', 'this.displayField', 'linkedid'], id: 'this.valueField', root: 'Records', listeners: { load: function () { if (this.startValue != '') { if (this.store.find('this.valueField', this.startValue) != '-1') { this.setValue(this.startValue); UpdateDependentComboboxStore('this.comboVarname', this.getValue(), 'this.name', 5, 'this.mode'); } } } } }) }, config)); }; Ext.reg('carterremotecombo', Ext.ux.CarterRemoteCombo);
Similar Threads
-
[SOLVED] question on factory function
By moegal in forum Ext 3.x: Help & DiscussionReplies: 0Last Post: 11 Aug 2010, 5:44 PM -
CRUD Factory
By mask_hot in forum Community DiscussionReplies: 4Last Post: 4 Mar 2010, 2:05 AM -
Ajax.request factory
By stricte in forum Ext 3.x: Help & DiscussionReplies: 1Last Post: 4 Jan 2010, 2:38 PM -
Factory Function File Pattern
By jsakalos in forum Ext 2.x: Help & DiscussionReplies: 6Last Post: 19 Apr 2009, 7:01 AM


Reply With Quote