1

我的 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 << "}"`

上面的代码不正确。

我的问题是如何获得在确认框中所做的选择(真或假)的值?

提前谢谢了。

4

1 回答 1

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 << "}"

我试过了,它似乎工作。

于 2012-07-30T12:18:42.140 回答