Knockout无法处理#fore;#39;

时间:2015-01-19 14:16:23

标签: javascript jquery html knockout.js

我是淘汰赛的新手。对于我的问题,我试图让它为每个项目,有一个按钮和textarea。 textarea将在页面加载时隐藏。如果我单击按钮,它将显示textarea,或隐藏它(切换)。我实现了以下代码,但是我收到了这个错误:

  

未捕获的ReferenceError:无法处理绑定“foreach:function   (){return projects}“消息:无法处理绑定”可见:   function(){return show}“消息:show未定义

查看型号:

function ProjectViewModel(proj) {
            //console.log(proj);
            var self = this;
            self.projects = ko.observableArray(proj);
            self.show = ko.observable(false);
            self.toggleTextArea = function () {
                self.show(!self.show());
            };
        };

HTML:

                <!-- ko foreach: projects -->
            <div id="eachOppyProject" style="border-bottom: 1px solid #eee;">
            <table>
                <tbody>
                    <tr>
                        <td><a data-bind="attr: { href: '/tools/oppy/' + guid }" style="font-size: 25px;"><span class="link" data-bind="    value: guid, text: name"></span></a></td>
                    </tr>
                    <tr data-bind="text: projectDescription"></tr>
<%--                    <tr data-bind="text: guid"></tr>--%>
                </tbody>
            </table>
                 <span class="forminputtitle">Have you done project this before?</span>  <input type="button" value="Yes" data-bind="click: $parent.toggleTextArea" class="btnOppy"/>
                <textarea placeholder="Tell us a little of what you've done." data-bind="visible: show, attr: {'id': guid }" class="form-control newSessionAnalyst" style="height:75px; " /><br />
                <span> <input type="checkbox" name="oppyDoProjectAgain" style="padding-top:10px; padding-right:20px;">I'm thinking about doing this again. </span>
            <br />
                </div><br />
                <!-- /ko -->

0 个答案:

没有答案