我正在使用select2 3.4.5。我想要一个看起来像文本输入但又有一个下拉搜索的输入字段(就像其他任何select2框一样)。我还希望允许用户输入自己的文本,并让其像文本框一样做出反应(即:单击以保存文本)。似乎将tagging和selectOnBlur结合起来可以达到目的,但我似乎无法使其正常工作。任何更喜欢前端事物的人都可以给出一些指示?
以下是jsfiddle的链接:http://jsfiddle.net/u8ngzs4h/
df_new <- df
for (i in 1:nrow(df)){
if (df$var1[i] %in% c("C", "D")){
if (df$var2[i] == "A"){
df_new$var1[i] <- df$var2[i]
df_new$var2[i] <- df$var1[i]
df_new$val1[i] <- df$val2[i]
df_new$val2[i] <- df$val1[i]
} else if (df$var3[i] == "A"){
df_new$var1[i] <- df$var3[i]
df_new$var2[i] <- df$var1[i]
df_new$var3[i] <- df$var2[i]
df_new$val1[i] <- df$val3[i]
df_new$val2[i] <- df$val1[i]
df_new$val3[i] <- df$val2[i]
} else {
df_new$var1[i] <- df$var4[i]
df_new$var2[i] <- df$var1[i]
df_new$var3[i] <- df$var2[i]
df_new$var4[i] <- df$var3[i]
df_new$val1[i] <- df$val4[i]
df_new$val2[i] <- df$val1[i]
df_new$val3[i] <- df$val2[i]
df_new$val4[i] <- df$val3[i]
}
}
}