這是我的建議。由於無法將jGrowl相對於DIV進行放置,無論是向左還是向右移動,我們都會在渲染後將其轉移。以下是我從原始示例中獲取的代碼。
(function($){
$.jGrowl.defaults.pool = 5;
$.jGrowl.defaults.sticky = true;
$.jGrowl.defaults.life = 2500;
$.jGrowl.defaults.closer = true;
$.jGrowl.defaults.open = function(e,m,o) {$("#jGrowl").css('right', $('#header').offset().left + 17);};
/**
* @todo Add the twitter avatars to tweets, via tweet.user["profile_image_url"]
* @todo Find a way to calculate the dates relatively
* @todo Test is a cookie plugin is available so that some of this data can be 'cached'
*/
$.jTweet = function(username , total) {
$.getJSON("http://twitter.com/status/user_timeline/" + username + ".json?count=" + total + "&callback=?", function(response) {
$.each(response, function(i, tweet) {
$.jGrowl((tweet.text.replace(/[A-Za-z]+:\/\/[A-Za-z0-9-_]+\.[A-Za-z0-9-_:%&\?\/.=]+/, function(m) {
return m.link(m);
})) + ' [' + tweet.source + ']' , {
header: tweet.created_at ,
});
});
});
};
$.jTweet('jquery', 5);
})(jQuery);
這裏最重要的部分是線:
$.jGrowl.defaults.open = function(e,m,o) {$("#jGrowl").css('right', $('#header').offset().left + 17);};
哪個jGrowl對象的右鍵屬性對齊到我的標題左側財產。這基本上轉移它的位置,使它看起來好像它在標題的div。
嗨,肯。我需要指定一個#id,所以在我的另一個Ajax調用成功,我可以做$('#something')。jGrowl('close'); ..這就是爲什麼我希望它工作並不總是這樣,如果例如下載jgrowl,在例子dirr的jquery.html中,你會發現自定義容器$('#test1')。jGrowl('message');等等,然後在身體關閉之前,你會發現
,所以它顯示在特定的位置(左下角的例子)。 – Karem 2010-08-22 10:04:26Karem,你能設置一個顯示問題的可訪問頁面嗎? – 2010-08-22 15:34:36