使用Struts 2 jQuery加载div [英] Load div using Struts 2 jQuery

查看:84
本文介绍了使用Struts 2 jQuery加载div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个基于struts的应用程序,并且我想基于sj:textfield中的内容加载div.我正在使用struts jquery插件. 必须通过将文本字段内容传递给struts动作来加载div.

I am creating a struts based application and i want to load a div based on content in a sj:textfield. I am using struts jquery plugin. The div has to be loaded by passing the textfield contents to a struts action.

任何人都可以告诉我该怎么做,因为我在任何地方都找不到该实例.

Can anyone tell me how to do so since I could not find any instance of this anywhere.

推荐答案

我不确定我是否正确.但我会尝试.查看下面的代码

i am not sure, if i got u right. but i will give a try. check out the code below

<s:form action="action">
  <sj:textfield name="name" value="value" label="label/>
  <sj:submit targets="myResultDiv"/>
</s:form>

<div id="myResultDiv"></div>

提交表单后,结果应显示在ID为"myResultDiv"的div中,请查看struts2 jquery插件页面

after you submit the form, the result should be appeared in the div with id "myResultDiv", check out the struts2 jquery plugin page strut2-jquery-plugin-showcase

<s:form id="myForm" action="action">
  <sj:textfield name="name" value="value" label="label" onChangeTopics="changeTopic"/>
</s:form>

<div id="myResultDiv"></div>
<script>
$.subscribe('changeTopic', function(event, data) {
var ui = event.originalEvent.ui;
if(ui.item) {
    $('#myResultDiv').html('<p>'+message+'</p>');
}
});
</script>

这篇关于使用Struts 2 jQuery加载div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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