1

I have the following Jquery Slider initializer that I want to add a simple comma after the end of a line that needs to be programatically populated.

$(function () {
    $("#slider").slider({
        value: 1,
        min: 1,
        max: @Model.Offer.PurchaseLimit, <---problematic comma
        step: 1,
        slide: function (event, ui){
            $("#amount").val(ui.value);
        }
    });
});

The comma gets underlined as a 'syntax error'. My guess is that Razor is trying to interpret the comma.

I have also tried to create a variable outside the javascript function like this:

var PurchaseMax = @Model.Offer.PurchaseLimit; <----problematic semi-colon

But the problem just becomes the semi-colon. What do I do to get this to work?

1
  • It appears that this problem only exists in the IDE. I ran the page and it appears to work just fine. Commented Mar 24, 2014 at 19:46

1 Answer 1

1

do like this:

max: @(Model.Offer.PurchaseLimit),

this way the scope of the razor expression is between @( and )

Sign up to request clarification or add additional context in comments.

1 Comment

But I still need the comma output as a string. I have commented above as it appears to work just fine when parsed but the IDE does not like it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.