Question

What does someObject.$() mean?

I am going through the tilecontainer-dbg files in sapui5 toolkit and found this :

var oDomRef = this.$();
or someObject.$()
Was it helpful?

Solution 2

in SAPUI5 both $ & jQuery are globals used for accessing jQuery functionality

this.$() is similar to jQuery('#this.sId')
or
document.getElementById(this.sId)

Returns the best suitable DOM node that represents this Element wrapped as jQuery object.

below is the code definition

/**
* Returns the best suitable DOM node that represents this Element wrapped as jQuery object.
* I.e. the element returned by {@link sap.ui.core.Element#getDomRef} is wrapped and returned.
*
* If an ID suffix is given, the ID of this Element is concatenated with the suffix 
* (separated by a single dash) and the DOM node with that compound ID will be wrapped by jQuery.
* This matches the UI5 naming convention for named inner DOM nodes of a control. 
* 
* @param {string} [sSuffix] ID suffix to get a jQuery object for
* @return {jQuery} The jQuery wrapped element's DOM reference
* @protected
*/

sap.ui.core.Element.prototype.$ = function(sSuffix) {
  return jQuery(this.getDomRef(sSuffix));
 };

OTHER TIPS

$ is just a legal symbol in javascript. So, this.$() or someObject.$() is just a method call on that object. That object has a property named $ that is a function (e.g. a method).

Here's an exmaple:

var obj = {
    "data": 3,
    "$": function() {
         return this.data;
    }
};

var val = obj.$();          // returns 3
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top