4
我有一個帶有兩個選擇字段的表單,我使用select2來匹配&標記插入到字段中的任何東西。我需要將由新行分隔的輸入列表轉換爲由空格分隔的列表(因爲IE不會自動執行此操作)。是否可以在選擇字段中更改輸入?
我有下面的代碼與任何<input>
領域工作得很好:
$('#editor').bind('paste', function (e) {
var clipped = window.clipboardData.getData('Text');
clipped = clipped.replace(/(\r\n|\n|\r)/gm, " "); //replace newlines with spaces
$(this).val(clipped);
alert(clipped);
return false; //cancel the pasting event
});
,但它似乎並沒有工作,如果#editor是<select>
場。
<form method="POST" action="/run" class="ui-widget" onsubmit=" return confirmSubmit(this, 'run',true) ">
Editor:
<select name="editor" id="editor" multiple style="width: 200px">
<option>ALL</option>
</select>
<input type="submit" value="Submit">
</form>
任何想法缺少什麼?
至於我能看到IE甚至不支持粘貼到選定的字段。 – Tomalak
它的工作原理是,如果我在select2選項中有'multiple style'和matcher。 – user3710760
我沒有用select2獲得任何「粘貼」事件。在這裏比較:http://jsfiddle.net/ct5172sk/ – Tomalak