1. #1
    Ext User
    Join Date
    Jan 2008
    Posts
    47
    Vote Rating
    0
    webdings is on a distinguished road

      0  

    Default missing : after property id

    missing : after property id


    I'd create a form, use it to submit data, I want to confirm all items within the form are valid, so I write a simple filter in my following code(red words), it alert me

    Code:
    	Ext.onReady(function(){
    						 
    		Ext.QuickTips.init();
    		
    		var newadmin = new Ext.FormPanel({
    				labelWidth: 150, // label settings here cascade unless overridden
    				labelAlign: 'right',
    				//url:'newadmin.jsp',
    				frame:true,
    				title: 'Register as Administrator',
    				bodyStyle:'padding:5px 5px 0',
    				width: 600,
    				defaults: {width: 312},
    				defaultType: 'textfield',
    		
    				items: [{
    						fieldLabel: 'Administrator Name',
    						name: 'adminName',
    						id: 'adminName',
    						allowBlank:false
    					},{
    						fieldLabel: 'Password',
    						inputType: 'password',
    						name: 'passwd',
    						allowBlank:false
    					},{
    						fieldLabel: 'Confirm Password',
    						inputType: 'password',
    						name: 'password_cf',
    						validator: vailda,
    						invalidText: ' Confirm password not equal to password',
    						allowBlank:false
    					},{
    						fieldLabel: 'Email',
    						name: 'emailadr',
    						vtype:'email'
    				}],
    				buttons: [{
    					text: 'Register',
    					if(items.isValid()){
    						handler:doSave
    					},
    					id:'btnSave'
    				},{
    					text: 'reset',
    					handler: function() {
    							newadmin.form.reset();
    					}
    				}]
    		});
    
    		function vailda()
    		{
    				if(Ext.get('passwd').dom.value==Ext.get('password_cf').dom.value)
    					return true;
    					else
    					return false;
    		}
    
    		function doSave(){
    				Ext.MessageBox.show({
    					msg: 'Data saving, please wait',
    					progressText: 'Saving',
    					width:300,
    					wait:true,
    					waitConfig: {interval:200},
    					icon:'ext-mb-save',
    					nimEl: 'btnSave'
    				});
    				newadmin.getForm().submit({
    					url:'newadmin_i.jsp',
    					method:'POST',
    					success: function(form, action){
    						Ext.MessageBox.hide();
    						Ext.MessageBox.alert('System Message', 'Data save success');
    						//newwin.hide();
    						//ds.load();
    					},
    					failure: function(form, action){
    						Ext.MessageBox.hide();
    						Ext.MessageBox.show({
    							title:'Error',
    							msg: 'Data save failure',
    							buttons: Ext.Msg.OK,
    							icon: Ext.MessageBox.ERROR
    						});
    					}
    				})
    		};
    
    		newadmin.render("newadmin");
    		Ext.getDom("adminName").focus();
    
    	});
    error message
    Code:
    missing : after property id
    [Break on this error] if(items.isValid()){\n
    Can any one told me which part I got wrong? thanks
    I LOVE EXTJS

  2. #2
    Ext User
    Join Date
    Jul 2007
    Posts
    3,128
    Vote Rating
    0
    devnull has a little shameless behaviour in the past

      0  

    Default


    Indeed, its telling you that the json isnt structured properly, which is true.
    This is invalid, since the "if" is not part of a property:value pair.
    Code:
    text: 'Register',
    if(items.isValid()){
      handler:doSave
    },
    id:'btnSave'
    you will ned to define the handler directly, and do you validation within it:
    Code:
    text: 'Register',
    handler: function(){
      if(items.isValid()){
        doSave();
      }
    },
    id:'btnSave'

  3. #3
    Ext User
    Join Date
    Jan 2008
    Posts
    47
    Vote Rating
    0
    webdings is on a distinguished road

      0  

    Default


    thanks alot
    I LOVE EXTJS

Thread Participants: 1