3

I tried below way to hide a success message after some time in contact us page. But Not working.

app\code\Eight25media\Messagehide\view\frontend\requirejs-config.js

var config = {
"map": {
    "*": {
        "Magento_Theme/js/view/messages": "Vendor_Module/js/view/messages",
    }
}
}

app\code\Eight25media\Messagehide\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);
    }
});
});

How can i give a time out to contact us success message?

  • try with - var storage = $.initNamespaceStorage('mage-cache-storage').localStorage; storage.remove('messages'); – Anas Mansuri May 28 at 6:36
  • @AnasMansuri where should i add this in my code? – Mujahidh May 28 at 6:39
  • replace with - $.cookieStorage.set('mage-messages', ''); setTimeout(function() { $(".messages").hide('blind', {}, 500) }, 5000); – Anas Mansuri May 28 at 7:44
  • @AnasMansuri sorry, i want to show the message and set a time out to hide the message. – Mujahidh May 28 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.