Hi,
I am new to Alfresco, this is my basic example.
Below is my sample code, which is to add button to dashlet.
As per my JS, it should show alert message when I click on button, but I am getting error as, Alfresco.SampleDashlet is not a constructor.
Please let me know where I did mistake.
/**
* Sample Hello World dashboard component.
*
* @namespace dashlet
* @class dashlet.HelloWorld
* @author
*/
(function()
{
/**
* YUI Library aliases
*/
var Dom = YAHOO.util.Dom,
Event = YAHOO.util.Event;
/**
* Alfresco Slingshot aliases
*/
var $html = Alfresco.util.encodeHTML,
$combine = Alfresco.util.combinePaths;
/**
* Dashboard HelloWorld constructor.
*
* @param {String} htmlId The HTML id of the parent element
* @return {MyCompany.dashlet.HelloWorld} The new component instance
* @constructor
*/
Alfresco.SampleDashlet = function(htmlId)
{
Alfresco.SampleDashlet.superclass.constructor.call(this, "Alfresco.SampleDashlet", htmlId, ["button"]);
/* Initialise prototype properties */
this.listWidgets = [];
return this;
};
/**
* Extend from Alfresco.component.Base and add class implementation
*/
YAHOO.extend(Alfresco.SampleDashlet, Alfresco.component.Base,
{
/**
* Object container for initialization options
*
* @property options
* @type object
*/
options:
{
},
/**
* Fired by YUI when parent element is available for scripting
*
* @method onReady
*/
onReady: function HelloWorld_onReady()
{
// Save a reference to the button in case we need it later
this.widgets.testButton = Alfresco.util.createYUIButton(this, "testButton", this.onButtonClick);
},
/**
* Button click event handler
*
* @method onButtonClick
*/
onButtonClick: function HelloWorld_onButtonClick(e)
{
console.log('Hi');
}
});
})();