开发者

Conditional compilation turned off warning when mixing razor and javascript

开发者 https://www.devze.com 2023-03-22 08:28 出处:网络
The following snippet trig开发者_如何学JAVAgers a \"Conditional compilation turned off\" warning in one of my views. Do you have an idea on how to fix it?

The following snippet trig开发者_如何学JAVAgers a "Conditional compilation turned off" warning in one of my views. Do you have an idea on how to fix it?

<script type="text/javascript">
    $(document).ready(function () {
        @RenderSection("JQueryDocumentReady",false)
    });
</script>

I tried to insert a semicolon at the end of the render section statement but it didn't help.

Thank you.


NOTE: Answer accepted because of alternative suggestion to the question, not solution given for the problem in title.

I'm not 100% sure what Conditional Compilation has to do with being in a <script> block, but I did find that wrapping the statements in parenthesis fixed the problem.

@(RenderSection("JQueryDocumentReady"))

I do think this method has a bit of code smell though. It's not a problem to just have a script section and assign things to document ready on each page. It really isn't going to save you much work, and it will force you to put javascript on views outside of script tags the way you have chosen to do it.


you can try

$(document).ready(function () { '@RenderSection("JQueryDocumentReady",false)'; });

0

精彩评论

暂无评论...
验证码 换一张
取 消