document.ready() is not working in MVC4 Razor
Javascript is not working in MVC4 Razor
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Feb 3, 2014, 10:33 PM EST
Use sections to render the javascript in main view.
in partial view,
@section partialJS
{
// Your js here
}
in Main view,
@RenderSection("partialJS", false)
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Feb 3, 2014, 8:59 PM EST
There is no document.ready available. You have to use jquery like this,
$(document).ready(function() {}).
If you are using like this, then let us know code which you are using?
Sasi ReddyRank #4,458 · 342 reputationPosted Feb 3, 2014, 10:19 PM EST
The second alert is not coming in my Razor View
Jaganathan BantheswaranRank #170 · 14.1K reputationPosted Feb 3, 2014, 10:31 PM EST