当前位置: 动力学知识库 > 问答 > 编程问答 >

java - Load div using Struts 2 jQuery

问题描述:

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>

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

EDIT 1

<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>
分享给朋友:
您可能感兴趣的文章:
随机阅读: