0

I would like to use Bootstrap Growl Message like this one https://github.com/mouse0270/bootstrap-growl in my JSF project, but I don't know how to config it. I want it to be showed when an action finished (it should return fail or success).

4

1 回答 1

1

我希望我能早点注意到这一点。如果你还在使用我的插件,你会怎么称呼它。

您还可以在Bootstrap Growl 网站(最新版本)上找到有关我的插件的文档和示例

如果使用版本 1.0.6 并且只想显示一条消息。

var request = $.ajax({...});

request.done(function( msg ) {
    $.growl('Successful', { type: 'success' });
}); 

request.fail(function( jqXHR, textStatus ) {
    $.growl({ title: 'Request failed: ', message: textStatus }, { type: 'success' });
});

如果使用 2.0.0 版本(昨天刚刚发布)并想要显示消息。在这个新版本中,您可以更新咆哮。

var growl = $.growl({ 
                    title: 'Please Wait... ', 
                    message: 'Updating Database'
                },{
                    type: 'info',
                    allow_dismiss: false,
                    delay: 0
                }),
    request = $.ajax({...});
request.done(function( msg ) {
    // Update growl with success info
    growl.update('title', 'Success ');
    growl.update('message', 'Your changes have been saved');
    growl.update('type', 'success');
    // Since we disabled both the dismiss and delay we have to close
    // the growl manually. This closes it after 5 seconds. 
    setInterval(function() {
            growl.close();
    }, 5000);
}); 

request.fail(function( jqXHR, textStatus ) {
    // Update growl with failed info
    growl.update('title', 'Request failed: ');
    growl.update('message', textStatus);
    growl.update('type', 'danger');
    // Since we disabled both the dismiss and delay we have to close
    // the growl manually. This closes it after 5 seconds.  
    setInterval(function() {
            growl.close();
    }, 5000);
});
于 2014-07-05T13:08:53.583 回答