我的rjs模板中有以下代码,显示一个确认框:
page << "r = confirm('Would you like to link this newly created author to the book?')"
我试过
`page << "if r == true {"`
#do action a
`page << "} else {"`
#do action b
`page << "}"`
上面的代码不正确。
我的问题是如何获得确认框中的选择值(真或假)?
非常感谢提前。
答案 0 :(得分:1)
尝试使用以下语法:
page << "var r = confirm('Would you like to link this newly created author to the book?');"
page << "if (r == true) {"
#do action a
page << "} else {"
#do action b
page << "}"
我试过了,似乎有效。