Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert razor c# string to jquery string [duplicate]

when i use this code as script i get this error in console :

Syntax Error: missing variable name

$(document).ready(function () {
        var multiselect = $("#TahiyeKonande").data("kendoMultiSelect");
        var arr = [];
        var t = @ttt;
        var tt = t.split(",");
        console.log(tt);
        // set the value of the multiselect.
        console.log(arr);
        multiselect.value(arr);
    });
like image 461
Mahdi_absz Avatar asked Apr 08 '26 18:04

Mahdi_absz


1 Answers

for convert razor viewbag string to js use double quotation

$(document).ready(function () {
        var multiselect = $("#TahiyeKonande").data("kendoMultiSelect");
        var arr = [];
        var t = "@ttt";
        var tt = t.split(",");
        console.log(tt);
        // set the value of the multiselect.
        console.log(arr);
        multiselect.value(arr);
    });
like image 183
sina rezaei Avatar answered Apr 10 '26 12:04

sina rezaei



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!