在按鈕點擊這樣設置文本框的值在開模態使用JavaScript動態
<a href="#edit-venue" class="btn green editButton" data-toggle="modal" data-id="2" data-placement="bottom" title="Edit"><i class="icon-note"></i></a>
莫代爾
<div id="edit-venue" class="modal fade portlet" tabindex="-1" aria-hidden="true">
<div class="modal-dialog">
<form class="form-horizontal" id="editVenue" method="post">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
<h4 class="modal-title">Edit Venue Detail</h4>
</div>
<div class="modal-body">
<div class="form-group">
<label class="control-label col-sm-3"><b>Venue12</b></label>
<div class="control-label col-sm-9 text-left">
<input id="venue" name="venue" class="form-control venue_name" placeholder="Enter venue" type="text">
<span class="error"></span>
<span class="error"></span>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-3"><b>Room/Stage</b></label>
<div class="control-label col-sm-9 text-left">
<input id="roomStage" name="roomStage" class="form-control" placeholder="Enter room/stage" type="text">
<span class="error"></span>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" data-dismiss="modal" class="btn red">Cancel</button>
<button type="button" data-dismiss="modal" class="btn green btn_save">Save</button>
</div>
</div>
</form>
</div>
</div>
開放模型當我點擊按鈕打開模式,我想上點擊按鈕動態使用javascript填充特定文本框中的數據。
按鈕點擊我得到響應這樣{"id":67,"value":"venue 1","Xvalue":"venue 1"}
我想:$('#venue_name').val(msg.value);
但不是#venue_name
我想用closest()
。
我該怎麼做?
查找'模型opened'事件,然後分配值.. – Rayon
你將只能得到你的模型後生成的文本元素是開放的,在上面的註釋中提到,查找'model-opened'事件,用一個存取器獲取文本框併爲其賦值... – gkb
使用'$('。venue_name')'而不是'$( '#_name')''value_name'是類名而不是id –