リモート入力で先読みの入力があります。うまくいきます!だから私はJqueryで新しい入力を追加しようとするとうまくいきません!ここで入力をダイナミックに作成した先読み
<input name="name" class="form-control typeahead typeaheadFluxClient" type="text">
<script type="text/javascript">
var flux = new Bloodhound({
datumTokenizer: function(item) {
return Bloodhound.tokenizers.whitespace(cleanAcronym(item.nom));
},
queryTokenizer: function(query) {
return Bloodhound.tokenizers.whitespace(cleanAcronym(query));
},
limit: 10,
remote: {
url: 'remote Url !',
replace: function (url, query) {
if ($('.typeaheadFluxClient:focus').val()) {
url += '?title=' + $('.typeaheadFluxClient:focus').val();
}
return url;
},
ttl:1,
filter: function(list) {
return $.map(list, function(ligne) { return {id:ligne.page_id}});
}
}
});
function initTypeAhead(no) {
var selection='.typeahead';
if (no) {
selection = selection+'-'+no;
}
$('.typeaheadFluxClient').typeahead({minLength: 1}, {
name: 'flux',
displayKey: 'nom',
source: flux.ttAdapter(),
templates: {
empty: [
'no type ahead',
'@lang('events.no_typeahead')',
'<span class="empty-message-details">',
'no type ahead',
'</span>',
'</div>'
].join('\n'),
suggestion: function (datum) {
var html=datum.nom;
return html
}
}
});
}
flux.initialize();
initTypeAheadClientFluxPages();
私は先行入力の同じクラスでjQueryを使って入力を追加しようとします:
は私のコードがあります!それは動作しませんでした:
$("#addbtn").on("click", function() {
var count = $(".associateFluxCLient").length;
var html = `<hr>
<div class="form-group">
<label for="object" class="col-sm-2 control-label">Nom</label>
<div class="col-sm-10">
<input name="fluxClientPageTitle[`+count+`]" class="form-control typeahead typeaheadFluxClient" type="text" >
</div>
</div>
`;
$("#container").append(html);
どうすれば解決できますか?