PP.Ui.fireEvent

Syntax

PP.Ui.fireEvent(domNode: HTMLElement, e: Object);

Parameters

domNode. HTML Item.

e. Parameters of the fired event.

Description

The fireEvent method fires the event of the DOM node.

Example

To execute the example, the HTML page must contain links to PP.js script file and to PP.css styles file in the <body> tag of the HTML page of the <div> item with the button identifier. In the onload event of the <body> tag it is necessary to specify the call of the createButton() function. Add the button on the page:

var button;
function createButton() {
    // Create button
    button = new PP.Ui.Button({
        // Set parent item
        ParentNode: document.getElementById("button"),
        // Set button contents
        Content: "Button",
    });
}

Add an event handler of the mouse button to the button and fire it:

// Create a message about button clicking
var msg = "Button is clicked";
// Add an event handler of the button mouse clicking to the button
button.addEvent(button.getDomNode(), 'click', function (sender, args) { console.log(msg) }, false);
// Create event of the mouse button clicking
var event = new MouseEvent('click');
// Fire the event of the mouse button clicking on the button
PP.Ui.fireEvent(button.getDomNode(), event);

As a result, the console displays the message about mouse button clicking:

Button is clicked

See also:

PP.Ui