如何使用jQuery更新HTML元素?

时间:2016-03-16 22:21:10

标签: jquery backbone.js

我有一个打开弹出窗口的按钮:

var RowView = Backbone.View.extend({
    events: {
        'click .my-transaction-grid span.my-icon-export' : 'myExport',
    },
    myExport: function(){
        var uniqueKey = this.model.get('uniqueKey');
        var initSubmitButton = function(){
            $("#submitButton").on('click', function(response, postdata){
                window.open('downloadFile.action?uniqueKey=' + key + "&$myFolder=" + $("#myFolder").val(), '_self');
            });
        };

        var callback = function(){
            initSubmitButton(uniqueKey);
            initPaginationGrid("myGrid", "foldersForm", uniqueKey, true, null, "folderPopup.action", initSubmitButton);
        };
        loadPopupEdit("folderPopup.action", {uniqueKey: uniqueKey, editMode: true}, callback);

弹出窗口是一个jsp文件,包含一个下拉列表,我可以从中选择一个值:

<div id="POPUP-CONTENT" class="my-container-popup">
    <s:form id="foldersForm">
        <div class="my-content">
            <table class="my-table">
                <tr>
                    <td class="my-field><s:select id="myFolder" name="myFolder" list="myFoldersList" listKey="code" listValue="value" emptyOption="true" tabindex="3"/></td>
                </tr>
            </table>
        </div>
    </s:form>
</div>

当我从下拉列表中选择一个值时,如何在我调用$("myFolder")的脚本中获取window.open()的更新值?

我得到的是什么:

downloadFile.action唯一键= ir8ej38&安培; MyFolder文件=

我想得到什么:

downloadFile.action唯一键= ir8ej38&安培; MyFolder文件= selectedFolder

1 个答案:

答案 0 :(得分:0)

好的想通了,应该用

window.open('downloadFile.action?uniqueKey=' + key + "&$myFolder=" + $("#myFolder :selected").text(), '_self');

而不是

window.open('downloadFile.action?uniqueKey=' + key + "&$myFolder=" + $("#myFolder").val(), '_self');