websanova / wPaint

jQuery Paint Plugin
http://wpaint.websanova.com
351 stars 128 forks source link

Menu items won't load on a second wPaint Instance #122

Closed heavybullets closed 6 years ago

heavybullets commented 6 years ago

When creating multiple instances of wPaint on the same page, there is an error that makes impossible to load the toolbar menu items icons.

The issue at hand is here wPaint.js (line 600)

menu.items[key].name = key;

// use default img if img not set
menu.items[key].img = _this.wPaint.options.path + (menu.items[key].img || menu.img);

The problem happens because the first time the wPaint is loaded, menu.items[key].img is not set, so the menu.img is loaded.. The second time though, menu.items[key].img is already set, and that value gets appended to the "path" variable again (it was appended the first time)

The fix would be to not re set the variable

Cheers