tags:

views:

71

answers:

2
$("body").trigger({
    type:"logged",
    user:"foo",
    pass:"bar"
});
+1  A: 

What your code does is:

  • Trigger an event called logged in the document.body element
  • pass user and pass to the event handler

I have no idea how to how to display that in "normal xhtml". Let's say we have defined a special event logged, this could be the handler

$(document.body).bind('logged', function(event, user, pass){
      // event = event object
      // user = foo
      // pass = bar
});
jAndy
A: 

The trigger method emulates an event occuring, there is no corresponding method in the standard DOM. To do the same without jQuery you would basically have to copy the code from jQuery (with reservations for any licence restrictions that would make this illegal).

I'm not sure what your example would really do, as it doesn't follow the syntax in the documentation. According to that, the trigger method needs an event name, and optionally an array of parameters:

If the event handler doesn't need the use of the environment of the event, you could just call it as a method:

body.someEventName(param1, param2);

However, your example is using custom properties in the event object, so it won't work for that exact case.

Guffa
@Guffa: It is well documented syntax. Actually, he copied from the API docs.
jAndy
@jAndy: Yes, you are right. I didn't see that as it's only covered briefly in one of the examples, but not at all in the syntax description.
Guffa