javascript - Calling a method via another method -


i know i'm missing basic. how invoke checkvalue method inside startup method (the commented line)? contained within view in mvc framework , custom api.

essentially, when startup runs, want alert() fire.

define(function(require) {   'use strict';   var class = require('common/class'),       moduleview = require('common/platform/moduleview');    var value = 0;    return class.create(     moduleview,     {        startup : function() {         value = 1;         //invoke checkvalue(value) somehow... this.checkvalue(value)?       },        checkvalue: function(value) {         if (value >= 1) {           alert("hello.");         }       }      }   );  }); 

how writing class this:

return class.create(modelview, modelview());  function modelview() {     this.startup = function() {         value = 1;         this.checkvalue(value);     }     this.checkvalue = function(value) {         if (value >= 1)             alert("hello.");     } } 

this way can use class multiple times declaring new instance.


Comments