Wednesday 15 July 2015

javascript - How to send properties to self made events? -


How to send properties for self-created events? Am I trying something like this ?? | Maybe there exists another structure to solve this task?

  var mme = document.getElementById ('MME'); Mme.event1 = function (PROP) {warning (propproperty); } Mme.event2 = function (warning) {warning (propproperty); } //////// mme.eventN = function (warning) {warning (propproperty); } $ (MME). Trigger ('EventX', {Property: 'Hello World!'});    

It will appear that you want both events and methods < Previous> // Basic method mme.event1 = function (argument) {warning (argument); }; // Resident event handler mme.onevent1 = function (event, logic) {warning (logic); }; // jQuery event handler $ (mme) .on ("event1", function (event, logic) {warning (argument);});

When you trigger an event, jQuery, jQuery handler, the original handler, will then call the original methods. Only the handlers will pass the parameter, the basic method is called without the parameter.

From jQuery v1.9.1, line 3018:

  elem [type] ();   

Type is the name of the event.

This jsFiddle shows all 3 being called:

No comments:

Post a Comment