weird string concat in JavaScript -
i got weird on string concat in jquery follow :
var name = button.data('name') var emailname = button.data('email') var username = button.data('username') var userstatus = button.data('active') var userid = button.data('id') alert(userid) var actionupdate = "{{action('usercontroller@update', "+userid+")}}" alert(actionupdate)
and result/alert userid 28723050-71e9-11e7-a0a9-e9f620359699 (uuid user id) when concated/joined, got actionupdate variable {{action('usercontroller@update', "userid")}} instead of {{action('usercontroller@update', "28723050-71e9-11e7-a0a9-e9f620359699")}} expected.
i tried join string , variable concat or +=, didn't result expected.
any alternatives , solution appreciated.
if, odd reason, want
{{action('usercontroller@update', "28723050-...9699")}}
with single-quotes around usercontroller@update
, double-quotes around userid
, think need
var userid = button.data('id') alert(userid) var actionupdate = "{{action('usercontroller@update', \""+userid+"\")}}" alert(actionupdate)
(i.e., need add escaped double-quote character on either side of concatenation part.)
Comments
Post a Comment