update({'icon'... not working after update({'icon'...
Updating the icon more than once doesn't work because .update() will always search/replace the initial icon\class instead of the actual icon\class.
Example:
var progress = $.notify({
icon: 'fa fa-refresh',
message: 'Working...'
})
// Do something
progress.update({
'icon': 'fa fa-times',
'message': 'That didn't work, retrying...'
]}
// Try again
progress.update({
'icon': 'fa fa-check',
'message': 'Done!'
})
The second update won't change the icon as the class will look like "fa fa-times fa-check" instead of "fa fa-check"
Fix: In bootstrap-notify.js on line 127 change
$icon.removeClass(self.settings.content.icon).addClass(commands[command]);
to
$icon.removeClass($icon.attr('class')).addClass(commands[command]);
so we replace the actual icon instead of the initial icon.
I'll update this to fix. But I can not use your suggestion. The problem with that is if, you use a custom template and set a class to the icon and I use the suggested code it will remove their custom css for their custom template.
Thank you for pointing this out. I'll look into it this weekend.
Legit concern, didn't think about this as i am not using a template...yet :)
My idea for a solution is when I update the icon, update the setting the is storing the icon value, this way when you call update it again it will use the previous value you update to. It will make the script one line longer but I currently do not see a way to avoid this.
I kinda had similar problem. (pseudocode)
myNotify = $.notify({
message : 'Notification with icon',
icon : 'path/to/my/icon.png'},
{icon_type : 'image'});
myNotify.update('icon', 'path/to/my/new/icon.png');
did not change the icon on the opened notify box. Turns out it added the new src to the parent element. On line 130 in the unminified js file, $icon var needs to be reassigned to the newly found img dom.
So, change
if (!$icon.is('img')) {
$icon.find('img');
}
to
if (!$icon.is('img')) {
$icon = $icon.find('img');
}
Hope that helps.