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

onSuccess / onFailure callbacks? #46

Open
giorgio79 opened this issue Jun 16, 2016 · 4 comments
Open

onSuccess / onFailure callbacks? #46

giorgio79 opened this issue Jun 16, 2016 · 4 comments
Milestone

Comments

@giorgio79
Copy link

Hello,

I would like to execute javascript after the element is highlighted, and it looks like js that comes right after findAndReplaceDOMText does not yet find the added element. Any tips? I am trying to add a qtip on the highlighted element.

@giorgio79
Copy link
Author

PS looks like it is going to be sg else, as the element exists when I console log it :P

@giorgio79
Copy link
Author

giorgio79 commented Jul 1, 2016

Hmmm, occasionally the replacement is too slow, and when I try to show a qtip2 on the replaced and wrapped element it is not yet ready by the time I init the qtip in the next line...Maybe an onSuccess event would be great after all. :)

@giorgio79 giorgio79 reopened this Jul 1, 2016
@jkupczak
Copy link

I'd love to be able to get a count of how many replacements happened once my script is done.

@padolsey
Copy link
Owner

@giorgio79 findAndReplaceDOMText is completely synchronous, so there's no need for a callback. (i.e. it will always have finished running by the time the next line of JS runs). I think you might be experiencing another issue. (Please post it up to JSFiddle if you'd like help)

@jkupczak Sounds like a reasonable feature. For now, FWIW, you can discern the number of matches via the reverts array, e.g.

var f = findAndReplaceDOMText(...);
console.log(f.reverts.length); // number of reverts will always === number of matches

@padolsey padolsey added this to the 1.0.0 milestone Dec 6, 2017
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

3 participants