1. #1
    Sencha User putty's Avatar
    Join Date
    Jan 2008
    Location
    Queensland, Australia
    Posts
    127
    Vote Rating
    0
    putty is on a distinguished road

      0  

    Default xtype:'textarea', to xtype:'htmleditor' problem

    xtype:'textarea', to xtype:'htmleditor' problem


    Hi,

    I am having a little problem that has me very confused.

    This code functions perfectly,

    PHP Code:

     
    function editWiki(){
          var 
    wikiText Ext.get('project-wiki');
          var 
    wikiTextValue wikiText.dom.innerHTML;

           if(!
    wikiText.editor){
                    var 
    height wikiText.getHeight() + 40;
               
    height 410;
               
            var 
    width wikiText.getWidth();

            
    wikiText.editor = new Ext.FormPanel({
            
    url:'save-form.php',
            
    frame:false,
            
    autoHeight:true,
            
    border:false,
            
    widthwidth,

            
    items: [{
                    
                    
    name'company',
                    
    valuewikiTextValue,
                    
    widthwidth,
                    
    heightheight,
                    
    hideLabeltrue
                
    },{
                    
    xtype:'hidden',
                    
    name'page'
                
    }
            ],

            
    buttons: [{
                
    text'Cancel',
                
    handler : function(){
                    
    wikiText.hide();
                    
    wikiText.dom.innerHTML wikiTextValue;
                    
    wikiText.editor.destroy();
                    
    wikiText.editor '';
                    
    wikiText.show();
                }
            },{
                
    text'Save',
                
    handler : function(){

                      
    wikiText.editor.getForm().submit({
                          
    waitMsg:'Saving Data...',
                          
    url'./include/data/pro-savewiki.php',

                          
    success: function( formaction ){
                          
    wikiText.hide();
                            
    wikiText.dom.innerHTML wikiText.editor.getForm().items.get(0).getValue();
                            
    wikiText.editor.destroy();
                            
    wikiText.editor '';
                            
    wikiText.show();
                          },

                          
    failure: function( formaction ){
                               
    Ext.MessageBox.alert('Failure''There was an error saving your data, please try again later.');
                          }

                       });
                }
            }]
        });

            
    wikiText.hide();
            
    wikiText.dom.innerHTML '';
                    
    wikiText.editor.render(wikiText.dom)
                    
    wikiText.show();
        }
      } 
    However if I replace xtype:'textarea', with xtype:'htmleditor', I get an error "B has no properties" in ext-all.js.


    I don't know how to debug this problem? Any help would be great.

    Thanks,
    Levi

  2. #2
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,502
    Vote Rating
    47
    Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Why not just hold a reference to the input field?

    Code:
    function editWiki(){
          var wikiText = Ext.get('project-wiki');
          var wikiTextValue = wikiText.dom.innerHTML;
    
           if(wikiText.editor){ // Reuse form if it's present
                wikiText.inputField.setValue(wikiTextValue);
            } else {
               wikiText.inputField = new Ext.form.HtmlEditor({     
                    name: 'company',
                    value: wikiTextValue,
                    hideLabel: true,
                    anchor: '100% 100%' // Will fill the form area.
               });
               
            wikiText.editor = new Ext.FormPanel({
            url:'save-form.php',
            frame:false,
            autoHeight:true,
            border:false,
            width: width,
    
            items: [wikiText.inputField,
                {
                    xtype:'hidden',
                    name: 'page'
                }
            ],
    
            buttons: [{
                text: 'Cancel',
                handler : function(){
                    wikiText.hide();
                    wikiText.dom.innerHTML = wikiTextValue;
                    wikiText.editor.destroy();
                    wikiText.editor = '';
                    wikiText.show();
                }
            },{
                text: 'Save',
                handler : function(){
    
                      wikiText.editor.getForm().submit({
                          waitMsg:'Saving Data...',
                          url: './include/data/pro-savewiki.php',
    
                          success: function( form, action ){
                          wikiText.hide();
                            wikiText.dom.innerHTML = wikiText.inputField.getValue();
                            wikiText.editor.destroy(); // Why destroy each time?
                            wikiText.editor = ''; // Woudn;t you want tio reuse it?;
                            wikiText.show();
                          },
    
                          failure: function( form, action ){
                               Ext.MessageBox.alert('Failure', 'There was an error saving your data, please try again later.');
                          }
    
                       });
                }
            }]
        });
    
            wikiText.hide();
            wikiText.dom.innerHTML = '';
                    wikiText.editor.render(wikiText.dom)
                    wikiText.show();
        }
      }

Thread Participants: 1