Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Classes developing

    I am using:
    SmartClient version 8.1.
    Mozilla FireFox

    I make the SmsHLayout class with some method and smartclient classes inside.
    Code:
    isc.defineClass("SmsHLayout", "HLayout");
    isc.SmsHLayout.addProperties({
    	testFunction: function (param){isc.say(param)},
    	initWidget: function () {
    		this.Super("initWidget", arguments);
    		this.addMember(
    			isc.IButton.create({
    				size: 24,
    				showRollOver: true,
    				showDisabled: false,
    				showDown: true,
    				prompt: "RefreshData",
    				hoverWrap: false,
    				click: function (){SmsHLayout.testFunction('TESTFUNCTION');}
    			})
    		);
    	}
    });
    I want to call the function "testFunction" by pressing the IButton. I tried using "this.testFunction()", "testFunction()", "SmsHLayout.testFunction()". But always
    "TypeError: this.testFunction is not a function @ .../SmsLayout.js:676"

    How can I Call "testFunction" function inside the class?

    #2
    The problem seems to be inside function body, try to add semicolon:
    testFunction: function (param){isc.say(param) ; },

    Comment


      #3
      The way you call it is on the class, not on the instance, what would need the method to be static (see addClassProperties). However, in your case, I assume you would rather have something like:

      Code:
      isc.defineClass("SmsHLayout", "HLayout");
      isc.SmsHLayout.addProperties({
      	testFunction: function (param){isc.say(param);},
      	initWidget: function () {
      		var me = this;
      
      		this.members = [
      			isc.IButton.create({
      				size: 24,
      				showRollOver: true,
      				showDisabled: false,
      				showDown: true,
      				prompt: "RefreshData",
      				hoverWrap: false,
      				click: function (){ me.testFunction('TESTFUNCTION'); }
      			})
      		];
      
      		this.Super("initWidget", arguments);
      	}
      });

      Comment

      Working...
      X