2010-12-08 30 views
3

當我響應網絡事件時,我想讓先前執行的(?)通知框消失。是否有KRL的方式告訴它走開,還是必須通過JavaScript來完成?如何使「通知」框消失

如果必須通過javascript完成,請提供示例

回答

3

New Shiny Awesomer Answer!

我以前的所有答案吸!你真正應該做的是觸發關閉按鈕上的點擊事件。

$K(".kGrowl-notification .close").trigger("click"); 

當您使用網絡事件進行響應時,只需發出JavaScript即可。

更好的例子應用:

ruleset a60x469 { 
    meta { 
    name "better-close-notify-example" 
    description << 
     better-close-notify-example 
    >> 
    author "Mike Grace" 
    logging on 
    } 

    rule put_notify_on_page { 
    select when pageview ".*" 
    { 
     // put notify on page 
     notify("Hello","I'm on your page") with sticky = true; 

     // raise web event 
     emit <| 
     setTimeout(function() { 
      app = KOBJ.get_application("a60x469"); 
      app.raise_event("clear_notify"); 
     }, 2000); 
     |>; 
    } 
    } 

    rule clear_notify { 
    select when web clear_notify 
    { 
     emit <| 
     $K(".kGrowl-notification .close").trigger("click") 
     |>; 
    } 
    } 
} 

OLD蹩腳的答案


有幾種方法,你可以做到這一點。

實例:

set_element_attr

set_element_attr(".kGrowl", "style", "display:none"); 

發射[刪除](惡)

emit <| 
    $K(".kGrowl").remove(); 
|>; 

發射[隱藏]

emit <| 
    $K(".kGrowl").hide(); 
|>; 

replace_html(惡)

replace_html(".kGrowl",""); 

完整的應用程序例如:

ruleset a60x468 { 
    meta { 
    name "example-clear-notify" 
    description << 
     example-clear-notify 
    >> 
    author "Mike Grace" 
    logging on 
    } 

    rule put_notify_on_page { 
    select when pageview ".*" 
    pre { 
     button =<< 
     <button id="clear-notify">Click me to clear the notify</button> 
     >>; 
    } 
    { 
     notify("Hello","I'm on your page") with sticky = true; 
     append("body", button); 
     emit <| 
     $K("#clear-notify").click(function() { 
      app = KOBJ.get_application("a60x468"); 
      app.raise_event("clear_notify"); 
     }); 
     |>; 
    } 
    } 

    rule clear_notify { 
    select when web clear_notify 
    { 
     replace_inner(".kGrowl",""); 
    } 
    } 
} 

實施例應用書籤:=>http://mikegrace.s3.amazonaws.com/forums/stack-overflow/example-clear-notify-dev_bookmarklet.html

實施例的應用程序上運行的例子。COM:

alt text

清除按鈕點擊:

alt text

+0

我不知道,我們有一個set_element_attr行動! – MEH 2010-12-08 17:59:42