JQuery .val()在Internet Explorer中不起作用

时间:2017-06-23 09:15:53

标签: jquery internet-explorer bootstrap-duallistbox

$(' .dual_select&#39)。VAL();这不起作用,并在Internet Explorer上返回空。有什么想法吗?

var self = this;
        var selectedOptions = $('.dual_select').val();
        for (i = 0; i < selectedOptions.length; i++) {
            self.membersToSave[i] = JSON.parse(selectedOptions[i]);
        }
        $.ajax({
            type: "PUT",
            url: teamUrl + '/' + self.team.id + '/teamMember',
            data: JSON.stringify(self.membersToSave),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                router.push('/');
            },
            failure: function (errMsg) {
                alert(errMsg);
            },
            beforeSend: function () { $(".loading").show(); },
            complete: function () { $(".loading").hide(); },
        });

1 个答案:

答案 0 :(得分:0)

Vue代码:

`var MemberEdit` = Vue.extend({
template: '#member-edit',
data: function () {
    return {
        team: '',
        teamMemberList: [],
        noMembers: [],
        membersToSave: []
    };
},
created: function () {
    this.fetchData();
},
mounted: function () {
    this.startDualList();
},
methods: {
    fetchData: function () {
        var self = this;
        $.get(teamUrl + "/" + self.$route.params.team_id, function (data) {
            self.team = data;
        });
        $.get(noMembersUrl, function (data) {
            self.noMembers = data;
            return data;
        });
        $.get(teamUrl + "/" + self.team.id + "/teamMember", function (data) {
            self.teamMemberList = data;
        });
    },
    updateMember: function () {
        var self = this;
        var selectedOptions = $('.dual_select').val();
        for (i = 0; i < selectedOptions.length; i++) {
            self.membersToSave[i] = JSON.parse(selectedOptions[i]);
        }
        $.ajax({
            type: "PUT",
            url: teamUrl + '/' + self.team.id + '/teamMember',
            data: JSON.stringify(self.membersToSave),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (data) {
                router.push('/');
            },
            error: function (errMsg) {
                alert(errMsg);
            },
            beforeSend: function () { $(".loading").show(); },
            complete: function () { $(".loading").hide(); },
        });
    },
    startDualList: function () {
        startDual();
    }
},
watch: {
    teamMemberList: function () {


    }
}

});

和jsp代码:

    <template id="member-edit">
    <section>
        <h4 class="label label-default pull-right"><i class="fa fa-user-plus"></i><CrmTagLib:CrmMsg key="teamManagement.label.addMember"/></h4>
        <div class="clearfix"></div>
          <form>
            <div class="alert alert-info"><CrmTagLib:CrmMsg key="teamManagement.alert.addMember.info" arg0='<strong>{{ team.name }}</strong>'/></div>
            <div class="clearfix"></div>
                <div class="form-group">
                    <select class="form-control dual_select" multiple>
                        <option v-for="noMember in noMembers" :value="JSON.stringify(noMember)">{{ noMember.name }}</option>
                        <option selected v-for="member in teamMemberList" :value="JSON.stringify(member)">{{ member.name }}</option>
                    </select>
                </div>
                <div class="btn-group btn-group-justified" role="group" aria-label="...">
                    <div class="btn-group" role="group">
                        <router-link class="btn btn-default" :to="{path: '/'}"><CrmTagLib:CrmMsg key="general.button.cancel"/></router-link>
                    </div>
                    <div class="btn-group" role="group">
                        <button v-on:click="updateMember" class="btn btn-info"><CrmTagLib:CrmMsg key="general.button.save"/></button>
                    </div>
                </div>
            </form>
    </section>
</template>