1. #1
    Sencha User mrtedweb's Avatar
    Join Date
    Feb 2009
    Posts
    55
    Vote Rating
    0
    mrtedweb is on a distinguished road

      0  

    Default Custom Events - %$#&*@

    Custom Events - %$#&*@


    Hello everyone,

    I'm trying to create a custom event that fires whenever data is received from an Ext.Ajax request. Firebug keeps telling me "this.fireEvent is not a function". Here's a simplified version of my code:

    Code:
    //Object Definition
    DataManager = Ext.extend(Ext.Panel, {
         initComponent:function() {
              console.log("initComponent");
              DataManager.superclass.initComponent.apply(this, arguments);
              this.addEvents('data');
         },
        
         sendAndReceive:function() {
              console.log("sendAndReceive");
              Ext.Ajax.request({
                   url: 'http://zeezor.thermosites.com/php/test.php',
                   success: this.onData,
              })
         },
        
         onData:function(objServerResponse) {
              console.log("onData");        
              this.fireEvent('data', this);
         }
    });
    
    //Object Instantiation & Usage
    var dataManager = new DataManager();
    dataManager.sendAndReceive();
    dataManager.on('data', function() {
         console.log("custom event received!");
    });
    I'm desperate. Can anyone help?
    Last edited by mrtedweb; 20 Feb 2009 at 5:31 PM. Reason: formatting correction

  2. #2
    Sencha User
    Join Date
    Mar 2007
    Posts
    7,854
    Vote Rating
    4
    tryanDLS is on a distinguished road

      0  

    Default


    Please post your code in CODE tags.

    Set a breakpoint in the onData - what is 'this' pointing to.

    Also, you're trying to fire an event called 'data' - have you defined that somewhere?

  3. #3
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    16,913
    Vote Rating
    630
    evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute evant has a reputation beyond repute

      0  

    Default


    You need to set the scope of your success handler.
    Evan Trimboli
    Sencha Developer
    Twitter - @evantrimboli
    Don't be afraid of the source code!

  4. #4
    Sencha User mrtedweb's Avatar
    Join Date
    Feb 2009
    Posts
    55
    Vote Rating
    0
    mrtedweb is on a distinguished road

      0  

    Default


    Thanks everyone!

Thread Participants: 2