KRL - 如何获得关注字段的价值?

发布于 2024-10-10 10:04:45 字数 267 浏览 0 评论 0原文

我正在查看页面上发生变化的字段。

watch("#searchbox","change");

如何获取更改后触发的规则中字段的新值?

我有这样的规则,

rule get_update is active {
 select when web change "#searchbox"
  ....
}

我不知道如何获得新值。我无法通过提交来观看它。

谢谢

I am watching a field on a page with a change.

watch("#searchbox","change");

How do you get the new value of the field in the rule that fires after it changes?

I have a rule like this

rule get_update is active {
 select when web change "#searchbox"
  ....
}

I cannot find out how to get the new value. I cannot use watch it with a submit.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

半葬歌 2024-10-17 10:04:45

我将猜测我认为您想要做什么:

您在页面上有一个输入,当用户输入输入时,您希望能够引发一个事件并从用户的输入中获取新值正在输入,这样您就可以对他们输入的内容做出反应。

基于我所做的假设:

监视操作不是您真正想要使用的,因为它只会引发正在监视的操作的事件,并且不随事件一起发送任何其他数据。您将需要编写一些自己的自定义 JavaScript 来

  • 监视用户键入
  • 从输入
  • raise Web 事件中获取新值,并将新值作为参数

以下是取自 http://kynetxappaday.wordpress.com/2010/12/16/day -8-raise-web-events-from-javascript/ 说明使用 JavaScript 中的参数引发 Web 事件

ruleset a60x488 {
  meta {
    name "raising-custom-web-events"
    description <<
      raising-custom-web-events
    >>
    author "Mike Grace"
    logging on
  }

  rule run_on_a_pageview {
    select when pageview ".*"
    {
      notify("Hello","I ran on a pageview") with sticky = true;
      emit <|
        app = KOBJ.get_application("a60x488");
        app.raise_event("custom_event_just_for_me", {"answer":42});
      |>;
    }
  }

  rule respond_to_custom_event_raised_from_emitted_js {
    select when web custom_event_just_for_me
    pre {
      answer = event:param("answer");
    }
    {
      notify("What is the answer?",answer) with sticky = true;
    }
  }
}

I am going to guess what I think you are trying to do:

You have an input on a page and when a user types in the input, you want to be able to raise an event and get the new value from the input that the user was typing into so you can react to what ever it is that they typed in.

Based on the assumptions I have made:

The watch action is not what you really want to use because it only raises an event on the action that it is watching and doesn't send any other data along with the event. You will want to write some of your own custom JavaScript to

  • watch for the user typing
  • get the new value from the input
  • raise web event with the new value as a parameter

Here is some sample code taken from http://kynetxappaday.wordpress.com/2010/12/16/day-8-raise-web-events-from-javascript/ that illustrates raising a web event with a parameter in JavaScript

ruleset a60x488 {
  meta {
    name "raising-custom-web-events"
    description <<
      raising-custom-web-events
    >>
    author "Mike Grace"
    logging on
  }

  rule run_on_a_pageview {
    select when pageview ".*"
    {
      notify("Hello","I ran on a pageview") with sticky = true;
      emit <|
        app = KOBJ.get_application("a60x488");
        app.raise_event("custom_event_just_for_me", {"answer":42});
      |>;
    }
  }

  rule respond_to_custom_event_raised_from_emitted_js {
    select when web custom_event_just_for_me
    pre {
      answer = event:param("answer");
    }
    {
      notify("What is the answer?",answer) with sticky = true;
    }
  }
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文