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

How do I pass arguments or parameters to the callback function? #34

Closed
Jeremy-Knudsen opened this issue Jun 1, 2017 · 1 comment
Closed

Comments

@Jeremy-Knudsen
Copy link

Hi there,

Thanks for the great script!

I have a problem that I've not been able to figure out yet. I want to be able to pass arguments to the data-scroll-showCallback function. Specifically, I would like to pass: 1) the HTML element that contains the data-scroll-showCallback attribute as the first argument; 2) a number; and 3) a Boolean.

Thank you for any help you can provide,
Jeremy

@terwanerik
Copy link
Owner

terwanerik commented Jun 6, 2017

Hi,

The html element is passed as this, the parameters are given as an array. So:
data-scroll-showCallback="myFunction(1, 'something')" calls:

function myFunction(number, string) {
  this.addClass('something') // this is the html element
  alert(number);
  alert(string);
}

I would pass a boolean as an integer, meaning 0 = false, 1 = true.

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

2 participants