This is a migrated thread and some comments may be shown as answers.

Window and partial view

2 Answers 170 Views
Window
This is a migrated thread and some comments may be shown as answers.
Adem
Top achievements
Rank 1
Adem asked on 20 Feb 2016, 08:28 AM
I want to use window with partial view.

There are two function in partial view. When window was opening I got error : "Uncaught SyntaxError: Unexpected token :"

If I remove second parameter(prm2) in second function(getCustomer2) then it works fine.(MyWindowPartial.cshtml line 14)

What can I do?

 

<script>
function getCustomer1()    {
     return {  wfTypeId : @(Html.Raw(Json.Encode(ViewBag.WfTypeId))), 
                folderIdList : @(Html.Raw(Json.Encode(ViewBag.WfTypeId)))        };   }
function getCustomer2()   {
    return  { wfTypeId : @(Html.Raw(Json.Encode(ViewBag.WfTypeId))),
                  prm2 : "deneme"       };
}
 </script>

2 Answers, 1 is accepted

Sort by
0
Adem
Top achievements
Rank 1
answered on 20 Feb 2016, 09:28 AM

if I surround with @section Scripts { <script>...</script> }  ıt worked fine. 

0
Slav
Telerik team
answered on 22 Feb 2016, 02:06 PM
Hello,

The problem appears to stem from the formatting of the JavaScript code. It is not visible in the code snippet, posted her, however you will notice it in the sample you attached.

There is a line break between the return statement and the object that should be returned by the getCustomer2 method. You need to create the object on the same line so it can be returned by the method:
function getCustomer1()
{
    return {
        wfTypeId: @(Html.Raw(Json.Encode(ViewBag.WfTypeId))),
        folderIdList: @(Html.Raw(Json.Encode(ViewBag.WfTypeId)))
    };
}
function getCustomer2()
{
    return {
        wfTypeId: @(Html.Raw(Json.Encode(ViewBag.WfTypeId))),
        prm2: "deneme"
    };
}


Regards,
Slav
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Window
Asked by
Adem
Top achievements
Rank 1
Answers by
Adem
Top achievements
Rank 1
Slav
Telerik team
Share this question
or