0

What is the equivalent of the following code in javascript

$("body").on("PhantomInitEvent", function(){
                getReviewData();
                supplies_onFocus();
            });

$("body").trigger("PhantomInitEvent");

Manu
  • 3,979
  • 7
  • 21
  • 25

2 Answers2

2

It's already in JavaScript. If, however, you mean what it would look like without jQuery:

document.body.addEventListener("PhantomInitEvent", function() {
    getReviewData();
    supplies_onFocus();
});
Fabrício Matté
  • 69,329
  • 26
  • 129
  • 166
Elliot Bonneville
  • 51,872
  • 23
  • 96
  • 123
  • document.addEventListener("PhantomInitEvent", function(e) { window.alert("Mika"+e.detail); getReviewData(); supplies_onFocus(); }); i am triggering the event like this // Create the event var event = new CustomEvent("PhantomInitEvent", { "detail": "Example of an event" }); window.alert("Banthu"+event); // Dispatch/Trigger/Fire the event document.dispatchEvent(event); it is not working – Manu Apr 25 '14 at 05:33
0
element.attachEvent('onPhantomInitEvent', handler);

element.addEventListener('PhantomInitEvent', handler, false);
Vikram Jakkampudi
  • 502
  • 1
  • 3
  • 16