Results 1 to 7 of 7

Thread: Ext equivalent to the jQuery method .live()

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Ext JS Premium Member
    Join Date
    Jun 2009
    Location
    Eastern WA, US
    Posts
    78
    Vote Rating
    0
      0  

    Default Answered: Ext equivalent to the jQuery method .live()

    Does such a thing exist or will I need to roll my own?

    http://api.jquery.com/live/

    Description: Attach an event handler for all elements which match the current selector, now and in the future.

  2. You achieve it by using the delegate option:

    http://docs.sencha.com/ext-js/4-1/#!...od-addListener

    Code:
    Ext.getBody().on('click', function(){
        console.log('You clicked foo');
    }, null, {
        delegate: '.foo'
    });

  3. #2
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,590
    Answers
    673
    Vote Rating
    873
      0  

    Default

    You achieve it by using the delegate option:

    http://docs.sencha.com/ext-js/4-1/#!...od-addListener

    Code:
    Ext.getBody().on('click', function(){
        console.log('You clicked foo');
    }, null, {
        delegate: '.foo'
    });
    Evan Trimboli
    Twitter - @evantrimboli

  4. #3
    Ext JS Premium Member
    Join Date
    Jun 2009
    Location
    Eastern WA, US
    Posts
    78
    Vote Rating
    0
      0  

    Default

    Had not seen the delegate argument, that is perfect - thanks!

  5. #4
    Ext JS Premium Member
    Join Date
    Jun 2009
    Location
    Eastern WA, US
    Posts
    78
    Vote Rating
    0
      0  

    Default

    Actually, one more quick question - delegate refers to a DOM selector, is there an option or a way to have delegate use ComponentQuery instead?

    It would be easy enough to bake that myself, just asking if it's already built in.

  6. #5
    Ext JS Premium Member
    Join Date
    Jun 2009
    Location
    Eastern WA, US
    Posts
    78
    Vote Rating
    0
      0  

    Default

    Is this alos a viable solution?

    Code:
    	        	Ext.util.Observable.observe(Ext.util.Observable);
    	        	
    	        	Ext.util.Observable.on('click', function(context, event, options) {
    		        	// intercept here
    	        	});

  7. #6
    Sencha - Ext JS Dev Team evant's Avatar
    Join Date
    Apr 2007
    Location
    Sydney, Australia
    Posts
    18,590
    Answers
    673
    Vote Rating
    873
      0  

    Default

    The equivalent to live would be the controller in the MVC structure.

    Otherwise, you could instantiate the EventBus yourself.
    Evan Trimboli
    Twitter - @evantrimboli

Posting Permissions

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