1 つのテキスト入力と 1 つの select2 要素 (バージョン 4.0.0) を持つフォームがあります。テキスト入力にフォーカスするときは、select2 を開きます。
これが私が試したことです:
<select list="userAccountsMap.values" listKey="accountNo" listValue="accountNo"/>
<input id="destinationAccount" type="text" name="destinationAccount">
<script type="text/javascript">
('select').each(function( index ) {
$(this).select2();
}
});
$("#destinationAccount").focus(function () {
$("select").trigger('select2:open');
});
</script>
しかし、それは仕事ではありません。ここでフィドルを参照してください:http://jsfiddle.net/Hatamikhah/73wypp1w/1/
私の問題が何であるかわかりません。