按钮使用jQuery append()但不使用kendo模板

时间:2014-04-08 14:05:04

标签: javascript jquery html templates kendo-ui

我正在研究一些使用剑道的东西,我有一个问题,我无法弄清楚如何解决它..

首先是我的代码:

HTML:

<div data-role="view" id="drawer-prendreRendezVous" data-layout="drawer-layout" data-title="Mondial Relay" data-before-show="SuiviColisViewHelper.I().PrendreRendezVousManageBeforeShow">
    <div id="headerPriseRendezVous" style="width:100%;height:40px;margin-top:6px;">
        <div id="headerPriseRendezVousImg" style="padding-top:4px;padding-left:8px;position:relative; float:left; ">
            <img src="./img/clock.png" />
        </div>
        <div id="headerPriseRendezVousImg" style="position: relative; float:left;margin-left:20px; margin-top:10px; font-style: italic; font-weight: bold;color:rgb(120,120,120);"> <span>Votre Rendez Vous</span>

        </div>
    </div>
    <div id="contentPriseRendezVous" data-template=""></div>
</div> 

模板:

<script type="text/x-kendo-template" id="contentPriseRendezVousTemplate">
    <div style="width:100%;height:2px;background-color:rgb(120,120,120); margin-top:5px;"></div>
    # for (var index = 0; index < Creneaux.length; ++index) {#
              <a href="drawer-finalisationPriseRendezVous" data-click="suiviColisControler.FinaliserRendezVous" data-date="#: Creneaux[index].Date #" data-heure-debut="#: Creneaux[index].HeureDebut #" data-heure-fin="#: Creneaux[index].HeureFin #" data-role="button">Test</a>
    #}#
</script>

我用来设置模板的代码:

var template = kendo.template($("#contentPriseRendezVousTemplate").html());
var result = template(obj);
$("#contentPriseRendezVous").html(result);

如果我这样做,它第一次工作,我得到我的按钮...... 但是如果我在那之后回去再回来,它就不再有用了......

如果我使用jQuery代替上面的代码:

for (var i = obj.Creneaux.length - 1; i >= 0; i--) {
   $("#contentPriseRendezVous").append('<a href="drawer-finalisationPriseRendezVous" data-click="suiviColisControler.FinaliserRendezVous" data-date="' + obj.Creneaux[i].Date + '" data-heure-debut="' + obj.Creneaux[i].HeureDebut + '" data-heure-fin="' + obj.Creneaux[i].HeureFin + ' " data-role="button"></a>');
};

它运作得非常好,这是我不明白的部分......我的模板有问题......我做的事情不好......

谢谢你的帮助;)

0 个答案:

没有答案