bootstrap-iconpicker icon indicating copy to clipboard operation
bootstrap-iconpicker copied to clipboard

Existing pickers trigger change event when modal is opened with icons

Open audas opened this issue 7 years ago • 1 comments

If we have iconpickers on a page, and subsequently load an iconpicker into a modal - then the existing iconpickers all emit a "change" event which causes icons to be inserted all over their target text fields.

It is fired when the javascript is loaded into the modal window - a requirement in my case as it is remote content for a bootstrap modal.

If you set the iconpicker to have no default icon - it does not fire.

However if you change an iconpicker to having an icon - it fires when the javascript is loaded into the modal.

audas avatar Dec 05 '17 00:12 audas

Follow up the initiation function

Iconpicker.prototype.setIconset

Calls the select function which fires the change event on line 382

this.select(op.icon);

Commenting this out fixes the problem however it does not set the initial icon (this is the problem). Either the initial icon needs to be set within the setIconset function or a parameter needs to be passed telling the select function not to trigger the change event. Or a global var - nope.

Am passing a second param to the select function telling it if it "setup" or "select" - only trigger the change event if it is a "select".

Works.

audas avatar Dec 05 '17 00:12 audas