问题
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"
/>
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>
回答1:
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>
来源:https://stackoverflow.com/questions/21266513/struts2-jquery-plugin-how-do-call-ajax-from-javascript-for-tag-select