“rails-backbone”gem:如何使用骨干js实现简单的js代码

时间:2014-03-06 09:08:18

标签: javascript ruby-on-rails backbone.js

我正在使用此代码如何使用backbone.js。我打算在rails中实现一个javascript代码。下面的代码给出了一个下拉菜单,其中包含一些默认设置和一个“编写您自己的问题”工具,只需单击此选项即可编写自己的问题。

当点击“编写您自己的问题”时,可以在下拉菜单下方显示的文本框中编写自己的问题,否则隐藏文本框。 我想将用户编写的字符串存储到我的数据库或rails模型中。请使用backbone.js建议我这样做的方法

<select onchange="CheckOther(this);">
            <option value="Select one question....">Select one question...</option>
            <option value="On which street did you grow up?">On which street did you grow up?</option>
            <option value="What was your first phone number?">What was your first phone number?</option>
            <option value="What was the make of your first car?">what was the make of your first car?</option>
            <option value="Write your own question...">Write your own question...</option>
</select>
<input type="text" id="TextBox1" name="TextBox1" style="display:none;" />
<script type="text/javascript">
 function CheckOther(selectBox)
    {
        if (selectBox.selectedIndex == selectBox.options.length - 1)
        {
            document.getElementById("TextBox1").style.display = "inline";

        }
        else
        {
            document.getElementById("TextBox1").style.display = "none";
            document.getElementById("TextBox1").value = "";
        }
    }
</script>

0 个答案:

没有答案