0

I was studying a colleague's code and I noticed an event that I haven't used before and I can't find it online either.

This is the code:

$('body').on('items-set', function(){ bindDropdown(); console.log('must bind event') }) 

That console log never runs, I don't see the message in the console. What does 'items-set' mean?

1
  • That looks like a custom even that your colleague either forgot to use or forgot to delete Commented Sep 4, 2014 at 9:42

3 Answers 3

2

It's most likely a custom event, triggered by the following code.

$('body').trigger('items-set'); 
Sign up to request clarification or add additional context in comments.

2 Comments

Nope, no trigger on that event in any of the js files associated with the project.
Found a trigger in a <script> tag inside a php file. Thanks!
2

'items-set' is not a standard javascript/jquery event. Most likely it is either a custom event created by the user or of some library that is included in the page.

And the obvious reason I can think of for the console.log not being called is that the event is not triggered..

Also, if you cant find the custom event declaration anywhere, could be a 'stray' segment of code that the developer forgot to delete and which doesn't really do anything?

Comments

-1

correct is 3 parameters of $.on method

$('body').on(EVENT_HERE, SELECTOR_HERE, function(){ bindDropdown(); console.log('must bind event') }) 

1 Comment

It has nothing to do with this, it works with 2 parameters too, see codepen. codepen.io/Radu/pen/tCuBE

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.