I want to modify (add some extra code within function body) the '_select' function in http://twitter.github.io/typeahead.js/releases/latest/typeahead.bundle.js file without actually modifying the file itself. When I console.dir the Typeahead object to see the hierarchy, I am unable to track exact location of the '_select' function. The console in chrome shows the function under '' node, I am not aware of what this is. So I would like to know how can I give new definition to '_select' function.
Asked
Active
Viewed 157 times
1 Answers
0
My guess is that you can override it with:
Typeahead.prototype._select = function(){console.log("changed it");}
The underscore indicates that select is private and should not be used directly or overridden. In future releases _select may do something completely different or doesn't exist at all so your code will break.

HMR
- 37,593
- 24
- 91
- 160
-
Thanks HMR.. but I exactly don't know the position in hierarchy of typeahead object.. So Typeahead.prototype._select this wouldnt work.. if you search js file you could find the '_select' function.. Can you plz now give the solution. – vinayakj Apr 21 '14 at 16:22
-
Maybe $.fn.typeahead.prototype ? – HMR Apr 21 '14 at 16:34
-
$.fun.typeahead.prototype TypeError: Cannot read property 'typeahead' of undefined – vinayakj Apr 21 '14 at 16:37
-
http://stackoverflow.com/questions/23200678/add-function-to-the-plugin-js-without-actually-modifying-js-file can you please help on this post too.. – vinayakj Apr 21 '14 at 16:47