Results 1 to 4 of 4

Thread: [PR4] Every times more more.......

  1. #1
    Sencha User jsveron23's Avatar
    Join Date
    Feb 2011
    Location
    Seoul, Korea
    Posts
    78
    Answers
    1
    Vote Rating
    2
      0  

    Default Unanswered: [PR4] Every times more more.......

    Code:
        pressSegBtn: function(btn) {
            console.log('1');
            var text  = btn.getText(),
                store = this.getBestList().getStore();
            
            store.clearFilter();
            console.log('2');
            store.on('refresh', function() {
                console.log('3');
            });
            console.log('4');
            store.filter('type', text);
            console.log('5');
        },
    safari console...

    스크린샷 2012-01-27 오후 5.26.22.jpg

  2. #2
    Sencha User edspencer's Avatar
    Join Date
    Jan 2009
    Location
    Palo Alto, California
    Posts
    1,939
    Answers
    29
    Vote Rating
    11
      0  

    Default

    Every time your pressSegBtn function is called it's adding your 'refresh' event listener again, which is why you see it logging '3' more and more often. You only have to call .on once to register your listener - after that it will always be called when the refresh event is fired.

    Usually what you should do is use .on inside a function that is only called once, like the constructor or the initialize function inside a Component. Take a look at the constructor function in examples/kitchensink/app/views/Toolbars.js in the Touch 2 SDK download for an example.
    Ext JS Senior Software Architect
    Personal Blog: http://edspencer.net
    Twitter: http://twitter.com/edspencer
    Github: http://github.com/edspencer

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

    Default

    approved the thread so everyone can participate.

  4. #4
    Sencha User jsveron23's Avatar
    Join Date
    Feb 2011
    Location
    Seoul, Korea
    Posts
    78
    Answers
    1
    Vote Rating
    2
      0  

    Default

    thx.

Posting Permissions

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