如何设置'选择'列表中的模态对话框-流星

How to set 'select' list in a modal dialog - Meteor?

本文关键字:模态 对话框 流星 列表 选择 设置 何设置      更新时间:2023-09-26

当我在模态对话框中添加'Edit'功能时,我设法设置了文本值。但是下拉的选择列表没有更新。

<template name="edit_deal">
 <button id="edit_btn" class="edit">Edit</button>
 <div id="edit_dialog" title="Edit opportunity">
  {{> Edit }}
 </div>
</template>
<template name="Edit">
 <form class="edit-deal">
    <select name="quarter">
     <option value="1">Q1</option>
     <option value="2">Q2</option>
     <option value="3">Q3</option>
     <option value="4">Q4</option>
    </select>
    <input type="text" name="cuname" placeholder="Customer Name" >
 </form>
</template>

.js

Template.edit_deal.events({
 'click #edit_btn': function(event, template) {
  $( "#edit_dialog" ).dialog('open');
  Deals.find({"_id" : this._id}).fetch();
  $('input[name="quarter"]').val(this.quarter);
  $('input[name="cuname"]').val(this.customerName);
 }
});

当"编辑"模式对话框弹出时,除了"选择"列表外,所有值都会更新。缺少了什么?谢谢你!

您正在搜索这样的输入标记:

$('input[name="quarter"]').val(this.quarter);

查找select:

$('select[name="quarter"]').val(this.quarter);