javascript - String() Function error - Uncaught SyntaxError: missing ) after argument list -


i have function in js

<script>      var currentlocation = window.location.href;      function addcardtotrello() {       trello.addcard({       url: currentlocation,       name: string({{ soproduct.product }}),       due: {{ soproduct.required_date|date:"short_date_format"  }}     });     }      </script> 

that gives me error

uncaught syntaxerror: missing ) after argument list

this how looks when parsed

<script>  var currentlocation = window.location.href;  function addcardtotrello() {   trello.addcard({   url: currentlocation,   name: string(1 4343rfcdc 54446),   due: 07/30/2016 }); }  </script> 

the error in line

 name: string(1 4343rfcdc 54446), 

when value id (numeric) works ok , not getting error.

what problem?

this error happens because javascript engine doesn't know '1 4343rfcdc 54446' string, need wrap quotes. , if so, wont need string constructor because string.

trello.addcard({   url: currentlocation,   name: "{{ soproduct.product }}",   due: "{{ soproduct.required_date|date:"short_date_format"  }}" }); 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -