Ember multiple property changes but want to trigger single event
        Posted  
        
            by 
                Ankur Agarwal
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Ankur Agarwal
        
        
        
        Published on 2012-11-09T21:50:43Z
        Indexed on 
            2012/11/14
            17:01 UTC
        
        
        Read the original article
        Hit count: 384
        
properties
|ember.js
I have a ArrayController for date picker with properties to and from. Now when user selects a new date range from the UI both to and from value changes.
So a function which observers on to and from is trigger twice for a single change in date range.
I want to trigger the function only one every date range change. Any suggestions how to do that with ember
    app = Ember.Application.create();
    app.Time = Ember.ArrayController.create({
        to: null,
        from: null,
        rootElement: "#time",
        debug1: function() {
            this.set('to', 1);
            this.set('from', 2);
        },
        debug2: function() {
            this.setProperties( {
                'to': 3,
                'from': 4
            });
        },
        debug3: function() {
            this.beginPropertyChanges();
            this.set('to', 5);
            this.set('from', 6);
            this.endPropertyChanges();
        },
        search: function() {
            alert('called');
        }.observes('to', 'from')
    });
© Stack Overflow or respective owner