Skip to content

Trigger an event after the state of a condition changed #18

Description

@Seb33300

Hello,

I need to detect when a condition has been triggered in order to run some extra process.

I tried to do something like this:

$('...').conditionize({
    ifTrue: [
        // ...
        function ($s) { $s.trigger('my-event-name'); }
    ],
    ifFalse: [
        // ...
        function ($s) { $s.trigger('my-event-name'); }
    ]
});

But unfortunately, the event is fired as many times as we have elements related to the condition.
(If I have 10 elements using the same data-condition, the event is triggered 10 times, every time the condition has changed)

It will be very useful if conditionize2 could natively fire some events that we can listen when conditions are triggered (eg conditionize.before / conditionize.after)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions