1

I'm trying to put a NumericTextBox into a Kendo template.

Here is the code:

<script type="text/x-kendo-template" id="clone-wizard-template">
    <p>Bitte wählen Sie, wie viele Male Sie möchten <br />die Aktionsgruppe fortschreiben:
    </p>

        @(Html.Kendo().NumericTextBox()
            .Name("custom")
           .Value(10)
           .ToClientTemplate())


    <br />
/*some other lines*/
</script>

Which is strangely rendered into this:

<script type="text/x-kendo-template" id="clone-wizard-template">
    <p>Bitte wählen Sie, wie viele Male Sie möchten <br />die Aktionsgruppe fortschreiben:
   </p>

        <input class="k-input" id="custom" name="custom" type="number" value="10" /><script>
    jQuery(function(){jQuery("\#custom").kendoNumericTextBox({});});
<\/script>


    <br />
/*some other lines*/

</script>

I cannot understand from where comes </script> tag...

I'm loading a template into a modal window by using this code:

        editAktionsgruppen.kendoWindow = $("<div />").kendoWindow({
            title: "Bestätigen",
            resizable: false,
            visable: false,
            modal: true
        }).html($("#clone-wizard-template").html()).data("kendoWindow");

Isn't this a correct way to input a control in the template?

4

1 回答 1

3

I would probably write it like this:

var popUpWindow = $("<div />").kendoWindow({
    title: "Bestätigen",
    resizable: false,
    content: {
       template: kendo.toString($('#clone-wizard-template').html())
    },
    visable: false,
    modal: true
});

//add kendo validation to popup window
$('#my-form').kendoValidator();

//initialise the numeric textbox (you could specify a class on the input and find
//by that instead instead of using an id)
$('#NumInput').kendoNumericTextBox();

//wire-up an ok/submit button
$(popUpWindow).find('.t-button').on('click', function() {
 var validator = $('#my-form').data('kendoValidator');

   if(valiator.validate()) 
   {
    // do stuff
   }
});

//show the window
$(popUpWindow).data('kendoWindow').center().open();

then the client template:

  <script type="text/x-kendo-template" id="clone-wizard-template">
<form id="my-form">
        <p>Bitte wählen Sie, wie viele Male Sie möchten <br />die Aktionsgruppe fortschreiben:
        </p>

         <input id="NumInput" name="NumInput" type="number" required data-required-msg="number required" />

        <br />
    /*some other lines*/
    <button type="button" class="t-button">my button</button>
</form>
    </script>
于 2013-05-14T15:25:54.583 回答