[javascript] Using Bootstrap Modal window as PartialView

I was looking to using the Twitter Bootstrap Modal windows as a partial view. However, I do not really think that it was designed to be used in this fashion; it seems like it was meant to be used in a fairly static fashion. Nevertheless, I think it'd be cool to be able to use it as a partial view.

So for example, let's say I have a list of Games. Upon clicking on a link for a given game, I'd like to request data from the server and then display information about that game in a modal window "over the top of" the present page.

I've done a little bit of research and found this post which is similar but not quite the same.

Has anyone tried this with success or failure? Anyone have something on jsFiddle or some source they'd be willing to share?

Thanks for your help.

The answer is

Yes we have done this.

In your Index.cshtml you'll have something like..

<div id='gameModal' class='modal hide fade in' data-url='@Url.Action("GetGameListing")'>
   <div id='gameContainer'>

<button id='showGame'>Show Game Listing</button>

Then in JS for the same page (inlined or in a separate file you'll have something like this..

$(document).ready(function() {
   $('#showGame').click(function() {
        var url = $('#gameModal').data('url');

        $.get(url, function(data) {


With a method on your controller that looks like this..

public ActionResult GetGameListing()
   var model = // do whatever you need to get your model
   return PartialView(model);

You will of course need a view called GetGameListing.cshtml inside of your Views folder..

Similar questions with javascript tag:

Similar questions with asp.net-mvc tag:

Similar questions with twitter-bootstrap tag: