Results 1 to 4 of 4

Thread: Problem creating my own class (ext.define)

  1. #1
    Sencha User
    Join Date
    Mar 2010
    Posts
    33
    Answers
    2
    Vote Rating
    1
      0  

    Default Answered: Problem creating my own class (ext.define)

    I created my own class:

    Code:
    Ext.define("AgisViewerLight.Modul.Template",{
             MenuClickEvent : null,
             ModulWindow: null,
             MenuItem: null,
    
    
             config: {
                 ModulID : "Template",
                 MenuPictureSource : "Pictures/om_logo_rot_viewer.png",
                 MenuPictureText : "TemplateModul",
                 Viewer : null,
                 Map : null
             },
        
             constructor: function(config) {
                 this.initConfig(config);
    
                 this.callParent();
    
                 this.ModulWindow = Ext.create('widget.window', {
                     height: 495,
                     width: 400,
                     layout: {
                         type: 'fit'
                     },
                     closeAction: 'hide',
                     collapsible: true,
                     title: 'My Window',
                     listeners: {
                         activate: function () {
                             this.removeCls("ModulWindow");
                             this.addCls("ModulWinodwActive");
                         },
                         deactivate: function () {
                             this.removeCls("ModulWinodwActive");
                             this.addCls("ModulWindow");
                         }
                     }
                 });
    
                 this.Viewer.ModulCollection.add(this);
    
                 return this;
             },
    
             show: function () {
                     this.ModulWindow.show();
                     return this;
             },
            
    
             enable: function(){
                MenuClickEvent = dojo.connect(this.MenuItem, "onclick", this.show);
                return this;
            }    
        });
    and I instantiate the Class like this

    Code:
            var pModulTest2 = Ext.create('AgisViewerLight.Modul.Template',{
                        Viewer: AGISViewerLight,
                        Map: AGISViewerLight.Map
                    });
              pModulTest2.enable();
    The enable-method binds the show-method to a clickevent from a html-image. Juts now all works like expectet. The troubles starts in when calling the show-method. from my click-event. The this-object is now the "click-object" (a image tag) a not my own class object. So I can't acces my ModulWindow object. I have to change the scope in some way.

    Could anyone help me?

  2. Code:
    var pModulTest2 = Ext.create('AgisViewerLight.Modul.Template',{
        Viewer: AGISViewerLight,
        Map: AGISViewerLight.Map
    });
    pModulTest2.enable();
    
    Ext.get('button_foo').on('click', function() {
        pModulTest2.show();
    });

  3. #2
    Sencha User jay@moduscreate.com's Avatar
    Join Date
    Mar 2007
    Location
    DC Area =)
    Posts
    16,364
    Answers
    102
    Vote Rating
    86
      0  

    Default

    Why are you using dojo to configure a click event?

    Also MenuClickEvent is a global that you're not doing anything with.

    you're not following JavaScript naming convention. It's only going to lead to confusion.

  4. #3
    Sencha User
    Join Date
    Mar 2010
    Posts
    33
    Answers
    2
    Vote Rating
    1
      0  

    Default

    I'm using Dojo for DOM manipulations und registering Events without crossbrowser problems. I can use also pure Jaca Script code.

    But you didn't give me any answer for my question. How can I bind my 'show' method to click event from a button outside my object?

  5. #4
    Sencha Premium User mankz's Avatar
    Join Date
    Nov 2007
    Location
    Stockholm, Sweden
    Posts
    3,147
    Answers
    33
    Vote Rating
    201
      0  

    Default

    Code:
    var pModulTest2 = Ext.create('AgisViewerLight.Modul.Template',{
        Viewer: AGISViewerLight,
        Map: AGISViewerLight.Map
    });
    pModulTest2.enable();
    
    Ext.get('button_foo').on('click', function() {
        pModulTest2.show();
    });

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •