2

I want to show popup box on simple HTML button click using jQuery in MVC3. What would be a sample of how to do this?

0

4 Answers 4

1

To handle button click events and show a div on the click you can do:

$("#button").click(function() {
    $("#yourDialog").show();
});

http://jsfiddle.net/yGtwT/

You could also use a jQuery Dialog to show a "popup".

$(document).ready(function() {
  $("#yourDialog").dialog();
}); 

$("#button").click(function() {
   $("#yourDialog").dialog('open');
});​

http://jqueryui.com/dialog/

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

Comments

0

Use something jquery library that contains modal dialog.

Comments

0

Here's how I display a pop up box that selects various tag values, first the html:

<div style="display: none">
    <div id="tagDialogBox" title="Add Tags">
    @* other html here *@
    </div>
</div>

Here's the jQuery, note that you need to add .parent().appendTo($("formname")) in order to allow the dialog fields to be submitted as part of the form:

function showTagDialogBox() {
    $('#tagDialogBox').dialog({
        autoOpen: true,
        title: "Select Tags",
        modal: true,
        height: 530,
        width: 800,
        buttons: {
            "Ok": function () {
                $(this).dialog("close");
            }
        }
    }).parent().appendTo($("form:first"));

    return false;
}

Comments

0

This is extremely simple.

<input type="button" onclick="$('dialogbox').dialog();"/>

Also, examples on the jquery ui page. This one is very simple (though it also includes animation, you can pull that out as an example)

http://jqueryui.com/dialog/#animated

Comments

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.