Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The problem is that <code>myNamespace.Item</code> is not a function, is an object, because you have a function that is immediately executed.</p> <p>You can for example, add the methods to the current object:</p> <pre><code>myNamespace.Item = function() { this.initialize = function(title,details,code) { // setting members of this Object this.title = title; this.details = details; this.code = code; }; this.display = function() { this.Position(); this.Show(); }; this.position = function() { // position my item in the DOM }; this.show = function() { // show my item in the DOM } }; </code></pre> <p>Or use the <code>prototype</code> property of the constructor function, to make the object instances created with the <code>new</code> operator inherit those methods:</p> <pre><code>// Object for my namesapce myNamespace.Item = function() { // constructor logic }; myNamespace.Item.prototype.initialize = function(title,details,code) { // setting members of this Object this.title = title; this.details = details; this.code = code; }; myNamespace.Item.prototype.display = function() { this.Position(); this.Show(); }; myNamespace.Item.prototype.position = function() { // position my item in the DOM }; myNamespace.Item.prototype.show = function() { // show my item in the DOM }; </code></pre> <p>Or a slightly shorter syntax:</p> <pre><code>myNamespace.Item = function() { }; myNamespace.Item.prototype = { initialize: function(title,details,code) { // setting members of this Object this.title = title; this.details = details; this.code = code; }, display: function() { this.Position(); this.Show(); }, position: function() { // position my item in the DOM }, show: function() { // show my item in the DOM }, constructor: myNamespace.Item // fix the constructor property }; </code></pre> <p>The benefit of using the <code>prototype</code> property is that the methods exist only in the <code>myNamespace.Item.prototype</code> object, while in the first example, each object will have its own function instances which is less memory-efficient.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload