简体   繁体   English

日历插件示例在.net上不起作用

[英]calendar plugin sample doen't work on .net

this code works in expamle html but when I tried to use it in aspx page doesn't work. 此代码在expamle html中有效,但是当我尝试在aspx页面中使用它时不起作用。 also I didn't udnerstand the code well. 我也不太理解代码。 for example <%= month %> used but there is no month also first time I see a html in a script tags, so I am unfamiliar with the coding style, looking for guidance. 例如使用<%= month %>但是第一次在脚本标记中看到html时也没有月份,因此我不熟悉编码样式,正在寻找指导。

        <div class="cal2">

            <script type="text/template" id="template-calendar">
                <div class="clndr-controls">
                    <div class="clndr-previous-button">&lsaquo;</div>
                    <div class="month"><%= month %></div>
                    <div class="clndr-next-button">&rsaquo;</div>
                </div>
                <div class="clndr-grid">
                    <div class="days-of-the-week">
                        <% _.each(daysOfTheWeek, function(day) { %>
                        <div class="header-day"><%= day %></div>
                        <% }); %>
                        <div class="days">
                            <% _.each(days, function(day) { %>
                            <div class="<%= day.classes %>"><%= day.day %></div>
                            <% }); %>
                        </div>
                    </div>
                </div>
                <div class="clndr-today-button">Today</div>
            </script>

        </div>

  <script src="json2.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
  <script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
  <script src= "moment-2.8.3.js"></script>

  <script src="../src/clndr.js"></script>

this is the plugin homepage http://kylestetz.github.io/CLNDR/ 这是插件主页http://kylestetz.github.io/CLNDR/

I'm pretty sure the issue will be because you're using Underscore templates: http://underscorejs.org/#template 我很确定问题将是因为您使用的是Underscore模板: http : //underscorejs.org/#template

Because Underscore uses <%= %> in the template markup, .NET uses the same delimiters so when the page is rendered, .NET incorrectly believes it can render the Underscore template. 因为Underscore在模板标记中使用<%= %> ,所以.NET使用相同的定界符,因此在呈现页面时,.NET错误地认为它可以呈现Underscore模板。

You need to tell Underscore to use different delimeters, try the following: 您需要告诉Underscore使用不同的分隔符,请尝试以下操作:

<div class="cal2">
    <script type="text/template" id="template-calendar">
        <div class="clndr-controls">
            <div class="clndr-previous-button">&lsaquo;</div>
            <div class="month">{%= month %}</div>
            <div class="clndr-next-button">&rsaquo;</div>
        </div>
        <div class="clndr-grid">
            <div class="days-of-the-week">
                {% _.each(daysOfTheWeek, function(day) { %}
                <div class="header-day">{%= day %}</div>
                {% }); %}
                <div class="days">
                    {% _.each(days, function(day) { %}
                    <div class="{%= day.classes %}">{%= day.day %}</div>
                    {% }); %}
                </div>
            </div>
        </div>
        <div class="clndr-today-button">Today</div>
    </script>
</div>
<script src="json2.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.5.2/underscore-min.js"></script>
<script>
  // Tell Underscore to use different template delimiters - {% %}
  _.templateSettings = {
    interpolate: /\{%=(.+?)%\}/g,
    escape:      /\{%-(.+?)%\}/g,
    evaluate:    /\{%(.+?)%\}/g
  };
</script>
<script src= "moment-2.8.3.js"></script>
<script src="../src/clndr.js"></script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM