Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1390
Line breaks inside templates
posted

Line breaks inside templates

Hi After upgrading to the 12.1 release the row templates logic gets ignored when they contain line-breaks.

I define the templates inside a script block e.g.

<script id="rowTemplate" type="text/x-jquery-tmpl">

         <tr>            

                 <td>

                          <div>$i</div>

                 </td>

                 <td>

                          <div>$i</div>                                      

                 </td>

                 <td>

                          <div>$i</div>                                      

                 </td>

                 <td>

                          <div>$i</div>                                      

                 </td>

                 <td>

                          <div>$i</div>                                      

                 </td>

                 <td>

                          <div>$i</div>                                      

                 </td>

                 <td>

                          <div>$i</div>                                      

                 </td>

                 <td>

                          <div>$i</div>                                      

                 </td>

         </tr>

</script>

 

And referenced as follow:

rowTemplate: $("#rowTemplate").text()

 

It makes the templates allot neater and effortless to update than when dealing with very complex column templates, rather than having the whole template on a single line.

I am able to implement it like this if I strip the line breaks from the text like:

rowTemplate: $("#rowTemplate").html().replace(/(\r\n|\n|\r)/gm,""),
Parents
No Data
Reply
  • 5105
    Offline posted

    Hi there,

    You can use $.trim on $('#id').text(). It will do the same thing. Let me know if this works!

    Thanks!

Children