Muhammad Ali
Muhammad Ali

Reputation: 873

Render MVC View Section From Jquery

Here is my MVC View section:

@section popups{
    <div class="popup-class" id="popup">
        <div class='btn-group' id='actions'>
            <div class='collapse navbar-collapse'>
                <ul class='actions'>
                    <li class='dropdown'>
                        <a href='#' class='dropdown-toggle grid-icon' data-toggle='dropdown'></a>
                        <ul class='dropdown-menu'>
                            <li><a href='#'>Product</a></li>
                            <li><a href='#'>Test</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
        <div class='clear'>
        </div>
            </div>
}

I want to call it from JavaScript file (only this section).How can i do that?

Upvotes: 0

Views: 61

Answers (1)

Felipe Oriani
Felipe Oriani

Reputation: 38608

There is no way to get a asp.net mvc section in javascript. What you can do is define an html element around the section on the layout page, a <div> for sample, and get this element, for sample, in your layout page:

<div id="popups">
@RenderSection("popups", false)
</div>

In your javascript code, just call this element, for sample:

$(function(){
   // call the element, call a method
   $("#popups").show();
});

You do not specify what you want to do with this.

Upvotes: 2

Related Questions