2010-12-08 3 views
3

웹 이벤트에 응답하면 이전에 수행 한 (?) 알림 상자를 사라지게하고 싶습니다. 그것이 사라지라고 말하는 KRL 방법이 있습니까? 아니면 자바 스크립트를 통해 완료해야합니까?"알림"상자를 사라지게하려면 어떻게해야합니까?

이 자바 스크립트를 통해 수행해야하는 경우, 예를

답변

3

새로운 반짝 Awesomer 응답을 제공하십시오!

내 모든 이전 답변 suck! 정말로해야 할 일은 닫기 버튼에서 클릭 이벤트를 트리거하는 것입니다.

$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

  • replace_inner action 통지를 제거하는 (악)과 없음
  • 예 :

    set_element_attr

    • emit 자바 스크립트 알림 표시에
    • 변경 스타일 숨기거나 교체

      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

    +1

    나는 반짝이는 새로운 대답을 좋아한다. :) – TelegramSam

    관련 문제