masch
masch

Reputation: 33

Does jquery have an equivalent of dojo.subscribe()?

Forgive my ignorance as I am not as familiar with jquery. Is there an equivalent to dojo.subscribe() ?

Do you know a solution in jquery ? There are jquery.connect but this plugin not work in my tests.

Upvotes: 0

Views: 522

Answers (1)

Rup
Rup

Reputation: 34408

Best guess from the description of subscribe in j08691's link: bind and trigger. These allow you to define arbitrarily-named events on DOM nodes and later call them with arguments.

It sounds like the dojo.subscribe does this document-globally; you could probably achieve the same by binding events to the document object itself but I suspect whatever you're doing it'll make sense to bind events to DOM nodes on your page instead.

e.g. your example script contains

this.validationSubscription
    = dojo.subscribe(this.elementId+"/validation", this, "_handleValidation");

You could instead

var _this = this;
$(element).bind("validation",
    function(event, flag) { _this._handleValidation(flag)); }
    );

and then later

$(element).trigger("validation", false);

Upvotes: 1

Related Questions