Struts2 jQuery 插件 + 如何从 javascript 调用 ajax 进行标签选择 [英] Struts2 jQuery plugin + How Do call ajax from javascript for tag select

查看:39
本文介绍了Struts2 jQuery 插件 + 如何从 javascript 调用 ajax 进行标签选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下一个代码运行良好..

The next code works good..

           <s:url id="remoteurl" action="jsonsample"/> 
            <sj:select 
                href="%{remoteurl}" 
                id="language" 
                onChangeTopics="reloadsecondlist" 
                name="language" 
                list="languageObjList" 
                listKey="myKey" 
                listValue="myValue" 
                emptyOption="true" 
                headerKey="-1" 
                headerValue="Please Select a Language"
                />

但是:这些代码加载 <s:url id="remoteurl" action="jsonsample"/> 一旦加载页面...我想从 javascript 执行操作这个:

but: these code load with <s:url id="remoteurl" action="jsonsample"/> as soon load the page... I want execute the action from javascript like this:

<div id="result" style="width: 100px; height: 100px; background-color: green;">Click me!</div>

<script type="text/javascript">
            $(document).ready(function() {
                $("#result").click(function() {

Here ... How execute the action "jsonsample"? and refresh in the select "language"
                });
            });
        </script>

推荐答案

<sj:select> 标签中有 reloadTopics 属性,它采用逗号分隔的列表将导致它重新加载的主题.将其添加到您的 <sj:select> 标记并使用 publish 函数发布事件.

There is reloadTopics attribute in <sj:select> tag which takes a comma delimited list of topics that will cause it to reload. Add it to your <sj:select> tag and publish event using publish function.

<sj:select ... reloadTopics="reloadSelect"/>

<script type="text/javascript">
  $(document).ready(function() {
    $("#result").click(function() {
      $.publish("reloadSelect");
    });
  });
</script>

这篇关于Struts2 jQuery 插件 + 如何从 javascript 调用 ajax 进行标签选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆