お世話になります。
Thymeleaf内で二つのselectboxを表示しており、
Ajaxを使用して、一つ目のselectboxが選択されたら、その値によって二つ目のselectboxのoptionを変更する というものを実装しようとしています。
Ajaxで値が返ってきたタイミングでhtmlを生成したいのですが、thタグがうまく反映されず、困っています。
Chromeの検証機能で実際に生成されたhtmlを見てみると、[(${user.lastname})]や[(${user.id})]の値は表示されているのですが、
thタグがそのまま表示されてしまって、うまく読み込めていません。
正しい記述方法をご教示頂けますと幸いです。
thymeleafのバージョンは2.0.0BUILD SNAPSHOT を使用しています。
<div class="form-group"> <label for="personselect" class="control-label col-xs-4">担当者</label> <div class="col-xs-12"> <select class="form-control" id="personselect" name="personselect"> <option value="" disabled selected>担当者を選択して下さい</option> <option id="personoption">-</option> </select> </div> </div>
$(function() { $('#destinationselect').change(function() { $.ajax({ url : 'select', type : 'POST', data: 'text' }).done(function(data) { $("#personoption").html("<option id='personoption' [# th:value=[(${user.id})] /] [# th:each='user : [(${users})]' /] [# th:text=[(${user.lastname})] /]></option>"); }).fail(function(data) { console.log('失敗'); }); }); });
あなたの回答
tips
プレビュー