How to merge these two code to make does them not conflict?

var model = application.behavior = new ApplicationBehavior(); application.behavior = new MODEL.ApplicationBehavior( application );

Answers

  • edited August 2015 Answer ✓

    Hello,

    You can build a hierarchy of prototypes to combine both the standard application behavior and the MobileFramework's application behaviors (and any of your own additional methods). In the code below, I'm adding a trcout method to the application behavior.

        var AppBehavior = function(content, data, dictionary) {
            ApplicationBehavior.call(this, content, data, dictionary);
        };
    
        AppBehavior.prototype = Object.create(MODEL.ApplicationBehavior.prototype, {
            trcout: { value: function(x) {
                trace(x);
            }}      
        });
    
        var model = application.behavior = Object.create(AppBehavior.prototype);
    

    Cheers,

    Will

  • I try to do it like the following, but it didn't work.

    var AppBehavior = function(content, data, dictionary) { ApplicationBehavior.call(this, content, data, dictionary); };

      AppBehavior.prototype = Object.create(MODEL.ApplicationBehavior.prototype,ApplicationBehavior.prototype );
    var model = application.behavior = Object.create(AppBehavior.prototype);
    
  • Can you give me some information on why you want to do this? I'll help me craft a better answer.

    Cheers,

    Will

Sign In or Register to comment.