Hide messages after certain interval
How to hide notification messages
like success message after adding product to cart or any error messages or notices after few seconds after they appear on the the frontend using knockout js
.
Example : When I am adding a product in the cart, a success message appear saying "product has been added to your cart". I want to hide this success message after 5 seconds after it appear on the screen.
magento-2.1 knockoutjs messages
add a comment |
How to hide notification messages
like success message after adding product to cart or any error messages or notices after few seconds after they appear on the the frontend using knockout js
.
Example : When I am adding a product in the cart, a success message appear saying "product has been added to your cart". I want to hide this success message after 5 seconds after it appear on the screen.
magento-2.1 knockoutjs messages
add a comment |
How to hide notification messages
like success message after adding product to cart or any error messages or notices after few seconds after they appear on the the frontend using knockout js
.
Example : When I am adding a product in the cart, a success message appear saying "product has been added to your cart". I want to hide this success message after 5 seconds after it appear on the screen.
magento-2.1 knockoutjs messages
How to hide notification messages
like success message after adding product to cart or any error messages or notices after few seconds after they appear on the the frontend using knockout js
.
Example : When I am adding a product in the cart, a success message appear saying "product has been added to your cart". I want to hide this success message after 5 seconds after it appear on the screen.
magento-2.1 knockoutjs messages
magento-2.1 knockoutjs messages
asked Jan 28 '17 at 4:54
Anshu MishraAnshu Mishra
5,19552657
5,19552657
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
Try following way:
Vendor/Module/view/frontend/requirejs-config.js
var config = {
"map": {
"*": {
"Magento_Theme/js/view/messages": "Vendor_Module/js/view/messages",
}
}
}
Vendor/Module/view/frontend/web/js/view/messages.js
define([
'jquery',
'uiComponent',
'underscore',
'Magento_Customer/js/customer-data',
'jquery/jquery-storageapi'
], function ($, Component, _, customerData) {
'use strict';
return Component.extend({
defaults: {
cookieMessages: ,
messages:
},
/** @inheritdoc */
initialize: function () {
this._super();
this.cookieMessages = $.cookieStorage.get('mage-messages');
this.messages = customerData.get('messages').extend({
disposableCustomerData: 'messages'
});
if (!_.isEmpty(this.messages().messages)) {
customerData.set('messages', {});
}
$.cookieStorage.set('mage-messages', '');
setTimeout(function() {
$(".messages").hide('blind', {}, 500)
}, 5000);
}
});
});
Clear cache.
I have tried and it is not showing any message at all.
– Anshu Mishra
Jan 30 '17 at 5:55
Delete pub/static/*, clear cache. Run setup:static-content:deploy.
– Sohel Rana
Jan 30 '17 at 6:31
I have tried after cleaning the pub/static and executing the command setup:static-content:deploy , but still no effect. I have added alert in the initialize function but it is not alerting at all. I guess js file is not included properly. It would be great if you can share if anything else is required as well.
– Anshu Mishra
Jan 30 '17 at 7:33
For my case, I use SR_StackExchange is module name. And it's working fine with luma theme.
– Sohel Rana
Jan 30 '17 at 7:50
1
I have checked on different machine and the code seems to be working. Thanks for your answer. One more thing that I want to know is, what is the purpose of parameters 'blind' and {} in hide function.
– Anshu Mishra
Jan 30 '17 at 8:58
|
show 3 more comments
we can do it from js mixin
in you custom module view/frontend/requirejs-config.js
var config = {
config: {
mixins: {
'Magento_Ui/js/view/messages': {
'NameSpace_Module/js/messages-mixin': true
}
}
}
};
messages-mixin.js
define([
'jquery'
], function($) {
'use strict';
return function(targetModule) {
return targetModule.extend({
onHiddenChange: function (isHidden) {
var self = this;
// Hide message block if needed
// if (isHidden) {
// setTimeout(function () {
// $(self.selector).hide('blind', {}, 500);
// }, 30000);
// }
}
});
};
});
add a comment |
Make a mixin as Kumar said but do not extend the Magento_Ui messages since those are for checkout etc but extend Magento_Theme messages.js. The full code is as follow.
requirejs-config.js
var config = {
'config': {
'mixins': {
'Magento_Theme/js/view/messages': {
'Bemeir_General/js/mixin/messages-mixin': true
}
}
}
};
messages-mixin.js
define([
'jquery',
'uiComponent',
'Magento_Customer/js/customer-data',
'underscore',
'jquery/jquery-storageapi'
], function ($, Component, customerData, _) {
'use strict';
return function (targetModule) {
targetModule.defaults.isHidden = false;
targetModule.defaults.listens.isHidden = 'onHiddenChange';
targetModule.defaults.selector = '.page.messages .messages';
return targetModule.extend({
initialize: function () {
let original = this._super();
console.log(targetModule.defaults);
return original;
},
initObservable: function () {
this._super()
.observe('isHidden');
return this;
},
isVisible: function () {
return this.isHidden(!_.isEmpty(this.messages().messages) || !_.isEmpty(this.cookieMessages));
},
removeAll: function () {
$(this.selector).find('.message').removeClass('show');
},
onHiddenChange: function (isHidden) {
let self = this;
if (isHidden) {
setTimeout(function () {
$(self.selector).find('.message').removeClass('show');
self.isHidden('false');
}, 5000);
}
}
});
};
});
Make sure to enlarge the timeout 5 secs it to low for customer to actually notice it and maybe click on the message etc.
Hope this will help someone. Also those who are interested please read this. https://alanstorm.com/magento-2-understanding-the-uielement-observe/
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f156844%2fhide-messages-after-certain-interval%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
Try following way:
Vendor/Module/view/frontend/requirejs-config.js
var config = {
"map": {
"*": {
"Magento_Theme/js/view/messages": "Vendor_Module/js/view/messages",
}
}
}
Vendor/Module/view/frontend/web/js/view/messages.js
define([
'jquery',
'uiComponent',
'underscore',
'Magento_Customer/js/customer-data',
'jquery/jquery-storageapi'
], function ($, Component, _, customerData) {
'use strict';
return Component.extend({
defaults: {
cookieMessages: ,
messages:
},
/** @inheritdoc */
initialize: function () {
this._super();
this.cookieMessages = $.cookieStorage.get('mage-messages');
this.messages = customerData.get('messages').extend({
disposableCustomerData: 'messages'
});
if (!_.isEmpty(this.messages().messages)) {
customerData.set('messages', {});
}
$.cookieStorage.set('mage-messages', '');
setTimeout(function() {
$(".messages").hide('blind', {}, 500)
}, 5000);
}
});
});
Clear cache.
I have tried and it is not showing any message at all.
– Anshu Mishra
Jan 30 '17 at 5:55
Delete pub/static/*, clear cache. Run setup:static-content:deploy.
– Sohel Rana
Jan 30 '17 at 6:31
I have tried after cleaning the pub/static and executing the command setup:static-content:deploy , but still no effect. I have added alert in the initialize function but it is not alerting at all. I guess js file is not included properly. It would be great if you can share if anything else is required as well.
– Anshu Mishra
Jan 30 '17 at 7:33
For my case, I use SR_StackExchange is module name. And it's working fine with luma theme.
– Sohel Rana
Jan 30 '17 at 7:50
1
I have checked on different machine and the code seems to be working. Thanks for your answer. One more thing that I want to know is, what is the purpose of parameters 'blind' and {} in hide function.
– Anshu Mishra
Jan 30 '17 at 8:58
|
show 3 more comments
Try following way:
Vendor/Module/view/frontend/requirejs-config.js
var config = {
"map": {
"*": {
"Magento_Theme/js/view/messages": "Vendor_Module/js/view/messages",
}
}
}
Vendor/Module/view/frontend/web/js/view/messages.js
define([
'jquery',
'uiComponent',
'underscore',
'Magento_Customer/js/customer-data',
'jquery/jquery-storageapi'
], function ($, Component, _, customerData) {
'use strict';
return Component.extend({
defaults: {
cookieMessages: ,
messages:
},
/** @inheritdoc */
initialize: function () {
this._super();
this.cookieMessages = $.cookieStorage.get('mage-messages');
this.messages = customerData.get('messages').extend({
disposableCustomerData: 'messages'
});
if (!_.isEmpty(this.messages().messages)) {
customerData.set('messages', {});
}
$.cookieStorage.set('mage-messages', '');
setTimeout(function() {
$(".messages").hide('blind', {}, 500)
}, 5000);
}
});
});
Clear cache.
I have tried and it is not showing any message at all.
– Anshu Mishra
Jan 30 '17 at 5:55
Delete pub/static/*, clear cache. Run setup:static-content:deploy.
– Sohel Rana
Jan 30 '17 at 6:31
I have tried after cleaning the pub/static and executing the command setup:static-content:deploy , but still no effect. I have added alert in the initialize function but it is not alerting at all. I guess js file is not included properly. It would be great if you can share if anything else is required as well.
– Anshu Mishra
Jan 30 '17 at 7:33
For my case, I use SR_StackExchange is module name. And it's working fine with luma theme.
– Sohel Rana
Jan 30 '17 at 7:50
1
I have checked on different machine and the code seems to be working. Thanks for your answer. One more thing that I want to know is, what is the purpose of parameters 'blind' and {} in hide function.
– Anshu Mishra
Jan 30 '17 at 8:58
|
show 3 more comments
Try following way:
Vendor/Module/view/frontend/requirejs-config.js
var config = {
"map": {
"*": {
"Magento_Theme/js/view/messages": "Vendor_Module/js/view/messages",
}
}
}
Vendor/Module/view/frontend/web/js/view/messages.js
define([
'jquery',
'uiComponent',
'underscore',
'Magento_Customer/js/customer-data',
'jquery/jquery-storageapi'
], function ($, Component, _, customerData) {
'use strict';
return Component.extend({
defaults: {
cookieMessages: ,
messages:
},
/** @inheritdoc */
initialize: function () {
this._super();
this.cookieMessages = $.cookieStorage.get('mage-messages');
this.messages = customerData.get('messages').extend({
disposableCustomerData: 'messages'
});
if (!_.isEmpty(this.messages().messages)) {
customerData.set('messages', {});
}
$.cookieStorage.set('mage-messages', '');
setTimeout(function() {
$(".messages").hide('blind', {}, 500)
}, 5000);
}
});
});
Clear cache.
Try following way:
Vendor/Module/view/frontend/requirejs-config.js
var config = {
"map": {
"*": {
"Magento_Theme/js/view/messages": "Vendor_Module/js/view/messages",
}
}
}
Vendor/Module/view/frontend/web/js/view/messages.js
define([
'jquery',
'uiComponent',
'underscore',
'Magento_Customer/js/customer-data',
'jquery/jquery-storageapi'
], function ($, Component, _, customerData) {
'use strict';
return Component.extend({
defaults: {
cookieMessages: ,
messages:
},
/** @inheritdoc */
initialize: function () {
this._super();
this.cookieMessages = $.cookieStorage.get('mage-messages');
this.messages = customerData.get('messages').extend({
disposableCustomerData: 'messages'
});
if (!_.isEmpty(this.messages().messages)) {
customerData.set('messages', {});
}
$.cookieStorage.set('mage-messages', '');
setTimeout(function() {
$(".messages").hide('blind', {}, 500)
}, 5000);
}
});
});
Clear cache.
edited Jan 28 '17 at 7:20
answered Jan 28 '17 at 7:13
Sohel RanaSohel Rana
21k34256
21k34256
I have tried and it is not showing any message at all.
– Anshu Mishra
Jan 30 '17 at 5:55
Delete pub/static/*, clear cache. Run setup:static-content:deploy.
– Sohel Rana
Jan 30 '17 at 6:31
I have tried after cleaning the pub/static and executing the command setup:static-content:deploy , but still no effect. I have added alert in the initialize function but it is not alerting at all. I guess js file is not included properly. It would be great if you can share if anything else is required as well.
– Anshu Mishra
Jan 30 '17 at 7:33
For my case, I use SR_StackExchange is module name. And it's working fine with luma theme.
– Sohel Rana
Jan 30 '17 at 7:50
1
I have checked on different machine and the code seems to be working. Thanks for your answer. One more thing that I want to know is, what is the purpose of parameters 'blind' and {} in hide function.
– Anshu Mishra
Jan 30 '17 at 8:58
|
show 3 more comments
I have tried and it is not showing any message at all.
– Anshu Mishra
Jan 30 '17 at 5:55
Delete pub/static/*, clear cache. Run setup:static-content:deploy.
– Sohel Rana
Jan 30 '17 at 6:31
I have tried after cleaning the pub/static and executing the command setup:static-content:deploy , but still no effect. I have added alert in the initialize function but it is not alerting at all. I guess js file is not included properly. It would be great if you can share if anything else is required as well.
– Anshu Mishra
Jan 30 '17 at 7:33
For my case, I use SR_StackExchange is module name. And it's working fine with luma theme.
– Sohel Rana
Jan 30 '17 at 7:50
1
I have checked on different machine and the code seems to be working. Thanks for your answer. One more thing that I want to know is, what is the purpose of parameters 'blind' and {} in hide function.
– Anshu Mishra
Jan 30 '17 at 8:58
I have tried and it is not showing any message at all.
– Anshu Mishra
Jan 30 '17 at 5:55
I have tried and it is not showing any message at all.
– Anshu Mishra
Jan 30 '17 at 5:55
Delete pub/static/*, clear cache. Run setup:static-content:deploy.
– Sohel Rana
Jan 30 '17 at 6:31
Delete pub/static/*, clear cache. Run setup:static-content:deploy.
– Sohel Rana
Jan 30 '17 at 6:31
I have tried after cleaning the pub/static and executing the command setup:static-content:deploy , but still no effect. I have added alert in the initialize function but it is not alerting at all. I guess js file is not included properly. It would be great if you can share if anything else is required as well.
– Anshu Mishra
Jan 30 '17 at 7:33
I have tried after cleaning the pub/static and executing the command setup:static-content:deploy , but still no effect. I have added alert in the initialize function but it is not alerting at all. I guess js file is not included properly. It would be great if you can share if anything else is required as well.
– Anshu Mishra
Jan 30 '17 at 7:33
For my case, I use SR_StackExchange is module name. And it's working fine with luma theme.
– Sohel Rana
Jan 30 '17 at 7:50
For my case, I use SR_StackExchange is module name. And it's working fine with luma theme.
– Sohel Rana
Jan 30 '17 at 7:50
1
1
I have checked on different machine and the code seems to be working. Thanks for your answer. One more thing that I want to know is, what is the purpose of parameters 'blind' and {} in hide function.
– Anshu Mishra
Jan 30 '17 at 8:58
I have checked on different machine and the code seems to be working. Thanks for your answer. One more thing that I want to know is, what is the purpose of parameters 'blind' and {} in hide function.
– Anshu Mishra
Jan 30 '17 at 8:58
|
show 3 more comments
we can do it from js mixin
in you custom module view/frontend/requirejs-config.js
var config = {
config: {
mixins: {
'Magento_Ui/js/view/messages': {
'NameSpace_Module/js/messages-mixin': true
}
}
}
};
messages-mixin.js
define([
'jquery'
], function($) {
'use strict';
return function(targetModule) {
return targetModule.extend({
onHiddenChange: function (isHidden) {
var self = this;
// Hide message block if needed
// if (isHidden) {
// setTimeout(function () {
// $(self.selector).hide('blind', {}, 500);
// }, 30000);
// }
}
});
};
});
add a comment |
we can do it from js mixin
in you custom module view/frontend/requirejs-config.js
var config = {
config: {
mixins: {
'Magento_Ui/js/view/messages': {
'NameSpace_Module/js/messages-mixin': true
}
}
}
};
messages-mixin.js
define([
'jquery'
], function($) {
'use strict';
return function(targetModule) {
return targetModule.extend({
onHiddenChange: function (isHidden) {
var self = this;
// Hide message block if needed
// if (isHidden) {
// setTimeout(function () {
// $(self.selector).hide('blind', {}, 500);
// }, 30000);
// }
}
});
};
});
add a comment |
we can do it from js mixin
in you custom module view/frontend/requirejs-config.js
var config = {
config: {
mixins: {
'Magento_Ui/js/view/messages': {
'NameSpace_Module/js/messages-mixin': true
}
}
}
};
messages-mixin.js
define([
'jquery'
], function($) {
'use strict';
return function(targetModule) {
return targetModule.extend({
onHiddenChange: function (isHidden) {
var self = this;
// Hide message block if needed
// if (isHidden) {
// setTimeout(function () {
// $(self.selector).hide('blind', {}, 500);
// }, 30000);
// }
}
});
};
});
we can do it from js mixin
in you custom module view/frontend/requirejs-config.js
var config = {
config: {
mixins: {
'Magento_Ui/js/view/messages': {
'NameSpace_Module/js/messages-mixin': true
}
}
}
};
messages-mixin.js
define([
'jquery'
], function($) {
'use strict';
return function(targetModule) {
return targetModule.extend({
onHiddenChange: function (isHidden) {
var self = this;
// Hide message block if needed
// if (isHidden) {
// setTimeout(function () {
// $(self.selector).hide('blind', {}, 500);
// }, 30000);
// }
}
});
};
});
answered Nov 5 '18 at 7:44
Pradeep KumarPradeep Kumar
5,36164373
5,36164373
add a comment |
add a comment |
Make a mixin as Kumar said but do not extend the Magento_Ui messages since those are for checkout etc but extend Magento_Theme messages.js. The full code is as follow.
requirejs-config.js
var config = {
'config': {
'mixins': {
'Magento_Theme/js/view/messages': {
'Bemeir_General/js/mixin/messages-mixin': true
}
}
}
};
messages-mixin.js
define([
'jquery',
'uiComponent',
'Magento_Customer/js/customer-data',
'underscore',
'jquery/jquery-storageapi'
], function ($, Component, customerData, _) {
'use strict';
return function (targetModule) {
targetModule.defaults.isHidden = false;
targetModule.defaults.listens.isHidden = 'onHiddenChange';
targetModule.defaults.selector = '.page.messages .messages';
return targetModule.extend({
initialize: function () {
let original = this._super();
console.log(targetModule.defaults);
return original;
},
initObservable: function () {
this._super()
.observe('isHidden');
return this;
},
isVisible: function () {
return this.isHidden(!_.isEmpty(this.messages().messages) || !_.isEmpty(this.cookieMessages));
},
removeAll: function () {
$(this.selector).find('.message').removeClass('show');
},
onHiddenChange: function (isHidden) {
let self = this;
if (isHidden) {
setTimeout(function () {
$(self.selector).find('.message').removeClass('show');
self.isHidden('false');
}, 5000);
}
}
});
};
});
Make sure to enlarge the timeout 5 secs it to low for customer to actually notice it and maybe click on the message etc.
Hope this will help someone. Also those who are interested please read this. https://alanstorm.com/magento-2-understanding-the-uielement-observe/
add a comment |
Make a mixin as Kumar said but do not extend the Magento_Ui messages since those are for checkout etc but extend Magento_Theme messages.js. The full code is as follow.
requirejs-config.js
var config = {
'config': {
'mixins': {
'Magento_Theme/js/view/messages': {
'Bemeir_General/js/mixin/messages-mixin': true
}
}
}
};
messages-mixin.js
define([
'jquery',
'uiComponent',
'Magento_Customer/js/customer-data',
'underscore',
'jquery/jquery-storageapi'
], function ($, Component, customerData, _) {
'use strict';
return function (targetModule) {
targetModule.defaults.isHidden = false;
targetModule.defaults.listens.isHidden = 'onHiddenChange';
targetModule.defaults.selector = '.page.messages .messages';
return targetModule.extend({
initialize: function () {
let original = this._super();
console.log(targetModule.defaults);
return original;
},
initObservable: function () {
this._super()
.observe('isHidden');
return this;
},
isVisible: function () {
return this.isHidden(!_.isEmpty(this.messages().messages) || !_.isEmpty(this.cookieMessages));
},
removeAll: function () {
$(this.selector).find('.message').removeClass('show');
},
onHiddenChange: function (isHidden) {
let self = this;
if (isHidden) {
setTimeout(function () {
$(self.selector).find('.message').removeClass('show');
self.isHidden('false');
}, 5000);
}
}
});
};
});
Make sure to enlarge the timeout 5 secs it to low for customer to actually notice it and maybe click on the message etc.
Hope this will help someone. Also those who are interested please read this. https://alanstorm.com/magento-2-understanding-the-uielement-observe/
add a comment |
Make a mixin as Kumar said but do not extend the Magento_Ui messages since those are for checkout etc but extend Magento_Theme messages.js. The full code is as follow.
requirejs-config.js
var config = {
'config': {
'mixins': {
'Magento_Theme/js/view/messages': {
'Bemeir_General/js/mixin/messages-mixin': true
}
}
}
};
messages-mixin.js
define([
'jquery',
'uiComponent',
'Magento_Customer/js/customer-data',
'underscore',
'jquery/jquery-storageapi'
], function ($, Component, customerData, _) {
'use strict';
return function (targetModule) {
targetModule.defaults.isHidden = false;
targetModule.defaults.listens.isHidden = 'onHiddenChange';
targetModule.defaults.selector = '.page.messages .messages';
return targetModule.extend({
initialize: function () {
let original = this._super();
console.log(targetModule.defaults);
return original;
},
initObservable: function () {
this._super()
.observe('isHidden');
return this;
},
isVisible: function () {
return this.isHidden(!_.isEmpty(this.messages().messages) || !_.isEmpty(this.cookieMessages));
},
removeAll: function () {
$(this.selector).find('.message').removeClass('show');
},
onHiddenChange: function (isHidden) {
let self = this;
if (isHidden) {
setTimeout(function () {
$(self.selector).find('.message').removeClass('show');
self.isHidden('false');
}, 5000);
}
}
});
};
});
Make sure to enlarge the timeout 5 secs it to low for customer to actually notice it and maybe click on the message etc.
Hope this will help someone. Also those who are interested please read this. https://alanstorm.com/magento-2-understanding-the-uielement-observe/
Make a mixin as Kumar said but do not extend the Magento_Ui messages since those are for checkout etc but extend Magento_Theme messages.js. The full code is as follow.
requirejs-config.js
var config = {
'config': {
'mixins': {
'Magento_Theme/js/view/messages': {
'Bemeir_General/js/mixin/messages-mixin': true
}
}
}
};
messages-mixin.js
define([
'jquery',
'uiComponent',
'Magento_Customer/js/customer-data',
'underscore',
'jquery/jquery-storageapi'
], function ($, Component, customerData, _) {
'use strict';
return function (targetModule) {
targetModule.defaults.isHidden = false;
targetModule.defaults.listens.isHidden = 'onHiddenChange';
targetModule.defaults.selector = '.page.messages .messages';
return targetModule.extend({
initialize: function () {
let original = this._super();
console.log(targetModule.defaults);
return original;
},
initObservable: function () {
this._super()
.observe('isHidden');
return this;
},
isVisible: function () {
return this.isHidden(!_.isEmpty(this.messages().messages) || !_.isEmpty(this.cookieMessages));
},
removeAll: function () {
$(this.selector).find('.message').removeClass('show');
},
onHiddenChange: function (isHidden) {
let self = this;
if (isHidden) {
setTimeout(function () {
$(self.selector).find('.message').removeClass('show');
self.isHidden('false');
}, 5000);
}
}
});
};
});
Make sure to enlarge the timeout 5 secs it to low for customer to actually notice it and maybe click on the message etc.
Hope this will help someone. Also those who are interested please read this. https://alanstorm.com/magento-2-understanding-the-uielement-observe/
answered 19 mins ago
Goran HorvatGoran Horvat
12
12
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f156844%2fhide-messages-after-certain-interval%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown