2015-04-30 45 views
0

我想用gritter jquery顯示通知。Jquery Gritter通知

當我插入更新數據的形式,會出現gritter通知。我該怎麼辦?

+0

什麼通知?你需要把它放在你的問題中。 –

回答

0
I have added extra parameter by customizing gritter.js 
I have added **notificationID** in popup for my notification popup to close popup dynamically even from database. 

**Here is my code**:- 
in jquery.gritter.js file. 
adding the parameter in gritter option 
     position: '', 
     class_name: '', // could be set to 'gritter-light' to use white notifications 
     fade_in_speed: 'medium', // how fast notifications fade in 
     fade_out_speed: 1000, // how fast the notices fade out 
     time: 6000, // hang on the screen for... 
     **notificationID: ''** 
    } 

// Public - options to over-ride with $.gritter.options in "add" 
     position: '', 
     fade_in_speed: '', 
     fade_out_speed: '', 
     time: '', 
     **notificationID: '',** 


// adding the dynamic id in dataId.... 
_tpl_close: '<a class="gritter-close" data-id="[[notificationID]]" href="#" tabindex="1">Close Notification</a>', 

//Put in Basics 
notificationID = params.notificationID || ''; 

//define in temp 
tmp = this._str_replace(
       ['[[title]]', '[[text]]', '[[close]]', '[[image]]', '[[number]]', '[[class_name]]', '[[item_class]]', '[[notificationID]]'], 
       [title, text, this._tpl_close, image_str, this._item_count, class_name, item_class, notificationID], tmp 
      ); 


In your js file like mine was notification.js 

$.gritter.add({ 
        title: val.title, 
        text: val.message, 
        notificationID: val.notification_id, 
        sticky: false, 
        time: '10000' 
       }); 


Very simple.Try It 
+0

請添加解釋,因爲不鼓勵使用代碼解答。 – namezero