DracoBlue / jsb

A very extendable Toolkit to inject Javascript Behaviour into rendered HTML without Inline Javascript. (jsb was formerly known as JsBehaviourToolkit)
http://dracoblue.net
Other
52 stars 8 forks source link

whenFired for all past events #23

Closed larslaade closed 8 years ago

larslaade commented 9 years ago

Currently jsb saves only the last event for whenFired. In my use-case i need all past events.

the setup:

I have two modules of the same kind:

<div class="jsb_ jsb_module" data-jsb="{"id":"foo-1"}"> ... </div>
...
<div class="jsb_ jsb_module" data-jsb="{"id":"foo-2"}"> ... </div>

fire before the modules are loaded events:

jsb.fireEvent('module::disable', {id: 'foo-1'});
jsb.fireEvent('module::disable', {id: 'foo-2'});

the module code has:

jsb.whenFired('module::disable', {id: this.id});

result: only the second event with id 'foo-2' fired expected: both are fired

Is it possible to get all past events?

DracoBlue commented 9 years ago

No ;(.

  1. Can you fire an event like: "module::status" and all disabled modules retrigger the "modules::disable" or "modules::enable" instead?
  2. Another workaround could be to trigger "modules::disable::12355" (some ID) and listen on a regexp like: /midules::disable::/? (with jsb 2.0 it will trigger only once on regexp with whenfired, but I could fix that.

Anyways the first way is 100% the prefered way ;)

Am Dienstag, 7. Juli 2015 schrieb Lars Laade :

Currently jsb saves only the last event for whenFired. In my use-case i need all past events.

the setup:

I have two modules of the same kind:

<div class="jsb_ jsb_module" data-jsb="{"id":"foo-1"}"> ...

...

<div class="jsb_ jsb_module" data-jsb="{"id":"foo-2"}"> ...

fire before the modules are loaded events:

jsb.fireEvent('module::disable', {id: 'foo-1'}); jsb.fireEvent('module::disable', {id: 'foo-2'});

the module code has:

jsb.whenFired('module::disable', {id: this.id});

result: only the second event with id 'foo-2' fired expected: both are fired

Is it possible to get all past events?

— Reply to this email directly or view it on GitHub https://github.com/DracoBlue/jsb/issues/23.

http://dracoblue.net

larslaade commented 9 years ago

ok, thank you anyway... i take the first way :)

DracoBlue commented 9 years ago

@larslaade please see #24 and the bugfix release in 2.0.1.

There was an issue with fireing and using whenFired in this case (if you use filtervalues). Rare Usecase, but looks similar to yours!

larslaade commented 9 years ago

Sorry, but 2.0.1 does not fix my problem. There is a typo with the versionnumber in jsb.js line 2 (2.1.0 instead of 2.0.1).

DracoBlue commented 9 years ago

We added jsb.fireStickyEvent in jsb 2.3.0. THis should resolve your ticket, doesn't it?