为什么如果jquery模板中的条件多次执行?

时间:2014-07-22 12:38:11

标签: javascript jquery json jquery-templates

<script language="javascript" type="text/javascript">
        $(function () {
            var attendees = { Name: "Hajan", Surname: "Selmani" };
              $("#attendeesTemplate").tmpl(attendees).appendTo("#attendeesList");
        });
        function test(a, b) {
            alert(a + " " + b);
            return 1;
        }
    </script>
<script id="attendeesTemplate" type="text/html">
        <li>
        {{if test(1,2)==1}}
            ${Name} ${Surname}
        {{/if}}        
        </li>
    </script>

为什么jquery模板中的if条件执行了4次?

0 个答案:

没有答案