javascript - Kendo template add space where code is -


so using bit of code create template kendo dropdown list

 <script id="itemtemplate" type="text/x-kendo-template">           #if(text.indexof('(deleted)') > -1){#     <span style="display:none"></span>     #}else{#     <span>#:text#</span>     #}#     </script> 

the problem here line of code being interpreted white space. mean white space being added. when bind function select event , try text of selected item

function typechanged(e) {    console.log(e.item.text()); } $("#...").data("kendodropdownlist").bind("select", typechanged); 

what console.log return text 2 empty lines above , 2 below. please refer picture. want know there way strip empty line beside calling trim function? enter image description here

additional info when added more line of code in the template added line

<script id="itemtemplate" type="text/x-kendo-template">     #if(text.indexof('(deleted)') > -1){}#  <-- added           #if(text.indexof('(deleted)') > -1){#     <span style="display:none"></span>     #}else{#     <span>#:text#</span>     #}# </script> 

enter image description here

when remove use of template

old:

        @(html.kendo().dropdownlistfor(m => m)               .bindto(list)               .datatextfield("text")               .datavaluefield("value")               .htmlattributes(attributes)               ...               .templateid("itemtemplate")               .valuetemplateid("tagtemplate")         ) 

new:

@(html.kendo().dropdownlistfor(m => m)               .bindto(list)               .datatextfield("text")               .datavaluefield("value")               .htmlattributes(attributes)               ...               < deleted >               .valuetemplateid("tagtemplate")         ) 

console.log() returns fine.

enter image description here

do need empty span tags? if not, can reverse logic in template empty spaces never created.

#if(text.indexof('(deleted)') == -1){#     <span>#:text#</span> #}# 

Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -