Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fire only once, total #79

Open
BawdyInkSlinger opened this issue Jan 29, 2021 · 3 comments
Open

Fire only once, total #79

BawdyInkSlinger opened this issue Jan 29, 2021 · 3 comments

Comments

@BawdyInkSlinger
Copy link

BawdyInkSlinger commented Jan 29, 2021

I don't think the { onceOnly: boolean } option works the way i want. I think it applies to each element it finds in the selector. I don't want this, I want something that I don't think the library can do: I want the observer to fire only once, regardless of how many elements I set it on.

e.g.,

$(document).arrive("li", { fireOnce: true}, function() {
   // tell me the FIRST TIME a li element shows up.
});

This is useful because I don't want to fire it until a li is visible on the page, but I also don't want to run the body of the function more than once.

Honestly, this and a lot of other useful features could be used if the API let you pass in a jquery instead of a string.

$(document).arrive($("li").first(), function() {
   // tell me the FIRST TIME a li element shows up.
});

Of course, the library is a black box to me, and I don't know if that's a feasible implementation.

@T35R6braPwgDJKq
Copy link

I have the same problem as well

document.arrive(".class", {fireOnAttributesModification:true,existing:true,onceOnly:true}, function() {
    document.unbindArrive(".class")
    console.log('only called once')
});

Unfortunately it is called for each element of class "class"

@jsabrooke
Copy link

I found this because I wanted to make sure that it was fired once for each element matching the selector.

The suggestion would be a non-obvious breaking change if changing the functionality of onceOnly, so if implemented it should be a new parameter, or at least make it an obvious breaking change by renaming onceOnly to onceOnlyPerElement and adding a new parameter for the new functionality.

@DATEx2
Copy link

DATEx2 commented Dec 15, 2023

Any news with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants