javascript - Add function to the plugin js without actually modifying js file -
I want to add the 'setInputDataId' function to the same level because the existing function 'selection' is actually in the plugin without js file Modifying the file itself so I would like to know how I can add a new function, I appreciate the help.
Existing code in the plugin:
_select: Select function (data) {this .input.setQuery (datum.value); This.input.setInputValue (datum.value, true); this._setLanguageDirection (); this.eventBus.trigger ("selected", datum.raw, datum.datasetName); this.dropdown.close (); _.defer (_bind (this.dropdown.empty, this.dropdown)); }, I need the new code:
_select: Select function (data) {this.input.setQuery (datum.value); This.input.setInputValue (datum.value, true); This.input.setInputDataId (datum.raw); this._setLanguageDirection (); this.eventBus.trigger ("selected", datum.raw, datum.datasetName); this.dropdown.close (); _.defer (_bind (this.dropdown.empty, this.dropdown)); }, And the 'setInputDataId' function is not originally plugged in, I also want to add this function.
The function body is:
setInputDataId: set function InputDataId (raw) {This. $ Input.attr ('data-id', raw.id); }, Please do this in Chrome's console tab:
console.dir ($ .fn.typeahead) Now expand the node function, then click 'Prototype' on Typairhead, then you can see the Tippahs' second closer, then you can see the 'Selected Method'. How can I modify this function.
Hierarchy:
function & lt; Function scope & gt; Closed (second) typewrite prototype
as an object to just add it File your script after the addition of the above file.
For example: _ functionName = function () {// implementation}; Already open the console and try it out there.
Enter and press enter, you must give objects contents. Then try the above pseudo code and stop! But unless you add it anywhere in a file explicitly, it will only survive until you close the browser.
Comments
Post a Comment