添加事件处理程序以离开输入框

时间:2018-12-14 02:12:03

标签: c# event-handling telerik

我想在用户在输入框中输入内容后在服务器端添加一些处理。用户离开输入框时。因此,处理将在服务器端触发。这是其中的代码 实例化Itemplate。

var myArray=[
    {id:123, value:"a", name:"e"},
    {id:124, value:"b", name:"f"},
    {id:125, value:"c", name:"g"},
    {id:126, value:"d", name:"h"}
  ];

  
function addOrRemove(object, arr){
    // index will be -1 if id is not in the array
    let index = arr.findIndex(item => item.id === object.id)
    if (index === -1) arr.push(object)
    else arr.splice(index, 1)
}

// this will remove the item becuase `124` already exists
addOrRemove({id:124, value:"Some Other Value", name:"Some Other Name"}, myArray)
console.log(myArray)

// this will push it back since it's no longer there.
addOrRemove({id:124, value:"Some Other Value", name:"Some Other Name"}, myArray)
console.log(myArray)

如何在用户离开输入框焦点的位置添加功能来处理输入?

0 个答案:

没有答案