http://jsbin.com/dajexiraca/2/edit?html,js,console,output
The docs say you can trigger a select2:select event and pass data via params.data.但是,我的templateSelection代码失败,因为缺少其他数据。考虑下面的代码示例。
javascript
// manually trigger the `select2:select` event
$('#example1').trigger({
type: 'select2:select',
params: {
data: {
customData: "Hello World" // NOT AVAILABLE INSIDE templateSelection function!!!
}
}
});