javascript snytax error

Can anyone see an issue with the syntax here?
The code compiles ...just complains that the syntax is not proper.
The error seems to be at the end of this line -
 isExpanded: <%= Model.ExpandYearCategoryTree ? "true" : "false" %>

Here is the script:

<script type="text/javascript">        
        <% if (Model.ShowYearCategoryTree)
        { %>
        require(['ListDocs/yearCategoryTreeViewModel'], function(viewModel) {
                years: [ <%= String.Join(",", Model.YearCategoryTreeYears) %>],
                fileAreaSiteId: <%= Model.SiteId %>,
                subscriberId: <%= Model.UserSessionVariables.SubscriberId %>,
                isExpanded: <%= Model.ExpandYearCategoryTree ? "true" : "false" %>
        <% } %>
        require(['ListDocs/fileDrop'], function(fileDrop) {
                fileDropPanel: document.body,
                subscriberId: <%= Model.UserSessionVariables.SubscriberId %>,
                getAddFilesData: function($fileDropItem) {
                    var data = { fileAreaSiteId: <%= Model.SiteId %> };
                    if($fileDropItem.hasClass("jqgrow")) {
                        data.documentId = $fileDropItem[0].id;

                    return data;

Open in new window

LVL 12
Robb HillSenior .Net Full Stack DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
Look at the "View Source" in the page to see if you are getting what you're expecting.
Tom BeckCommented:
Ternary operations have to be assigned in C#. They cannot be standalone statements.

I'm wondering if you can just cast the boolean to a string.

<%= Model.ExpandYearCategoryTree.ToString() %>
Robb HillSenior .Net Full Stack DeveloperAuthor Commented:
no its a boolean
Your Guide to Achieving IT Business Success

The IT Service Excellence Tool Kit has best practices to keep your clients happy and business booming. Inside, you’ll find everything you need to increase client satisfaction and retention, become more competitive, and increase your overall success.

Tom BeckCommented:
I know it's a boolean but if the isExpanded property requires a string value...
Robb HillSenior .Net Full Stack DeveloperAuthor Commented:
I dont know..its strange...if I end it with a comma the error goes away..but am not sure how thats effecting the that does not seem like proper syntax
Tom BeckCommented:
Have you looked at the source of the rendered page as Dave suggested? What (if anything) is being filled in for the isExpanded value?

What you are really lacking in that whole initializer are default values in case the inline server side code produces nothing. Emptiness is not a valid value in a javascript Object array. If any of those inline code blocks produce nothing, your javascript will fail.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Robb HillSenior .Net Full Stack DeveloperAuthor Commented:
Tom BeckCommented:
You're welcome. Glad to help. Thanks for the points.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.