Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8503661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:48:59+00:00 2026-06-11T01:48:59+00:00

I am trying to add a modal window to an asp.net 4.0 app. Currently

  • 0

I am trying to add a modal window to an asp.net 4.0 app.
Currently the Modal window opens on an Anchor click
I would like to have it open with a button click.

It looked to me like I just needed to modify my jquery selector to fire on button click but that does not appear to be working.

ie. $(“:button”).live(“click”, function (e) { should fire on button click

Working code to fire on a link is below.

MarkUp:

<a href="#" data-reveal-id="myModal">
    Add User
</a>

JQuery File:

(function ($) {
$("a[data-reveal-id]").live("click", function (e) {
    e.preventDefault();
    var modalLocation = $(this).attr("data-reveal-id");
    $("#" + modalLocation).reveal($(this).data())
});
$.fn.reveal = function (options) {
    var defaults = { animation: "fadeAndPop", animationspeed: 300, closeonbackgroundclick: true, dismissmodalclass: "close-reveal-modal" };
    var options = $.extend({}, defaults, options); return this.each(function () {
        var modal = $(this), topMeasure = parseInt(modal.css("top")),topOffset = modal.height() + topMeasure, locked = false, modalBG = $(".reveal-modal-bg");
        if (modalBG.length == 0) { modalBG = $('<div class="reveal-modal-bg" />').insertAfter(modal) } modal.bind("reveal:open", function () {
            modalBG.unbind("click.modalEvent");
            $("." + options.dismissmodalclass).unbind("click.modalEvent");
            if (!locked) {
                lockModal();
                if (options.animation == "fadeAndPop") {
                    modal.css({ top: $(document).scrollTop() - topOffset, opacity: 0, visibility: "visible" });
                    modalBG.fadeIn(options.animationspeed / 2);
                    modal.delay(options.animationspeed / 2).animate({ top: $(document).scrollTop() + topMeasure + "px",opacity: 1},options.animationspeed, unlockModal())
                }
                if (options.animation == "fade") {
                    modal.css({ opacity: 0, visibility: "visible", top: $(document).scrollTop() + topMeasure });
                    modalBG.fadeIn(options.animationspeed / 2);
                    modal.delay(options.animationspeed / 2).animate({ opacity: 1 }, options.animationspeed, unlockModal())
                }
                if (options.animation == "none") {
                    modal.css({ visibility: "visible", top: $(document).scrollTop() + topMeasure });
                    modalBG.css({ display: "block" });
                    unlockModal()
                }
            } modal.unbind("reveal:open")
        });
            modal.bind("reveal:close", function () {
            if (!locked) {
                lockModal();
                if (options.animation == "fadeAndPop") {
                    modalBG.delay(options.animationspeed).fadeOut(options.animationspeed);
                    modal.animate({ top: $(document).scrollTop() - topOffset + "px", opacity: 0 }, options.animationspeed / 2, function () {
                        modal.css({ top: topMeasure, opacity: 1, visibility: "hidden" });
                        unlockModal()
                    })
                }
                if (options.animation == "fade") {
                    modalBG.delay(options.animationspeed).fadeOut(options.animationspeed);
                    modal.animate({ opacity: 0 }, options.animationspeed, function () { modal.css({ opacity: 1, visibility: "hidden", top: topMeasure }); unlockModal() })
                }
                if (options.animation == "none") {
                    modal.css({ visibility: "hidden", top: topMeasure });
                    modalBG.css({ display: "none" })
                } 
            } modal.unbind("reveal:close")
        });
        modal.trigger("reveal:open");
        var closeButton = $("." + options.dismissmodalclass).bind("click.modalEvent", function () { modal.trigger("reveal:close") });
        if (options.closeonbackgroundclick) {
            modalBG.css({ cursor: "pointer" });
            modalBG.bind("click.modalEvent", function () { modal.trigger("reveal:close") })
        }
        $("body").keyup(function (e) {
        if(e.which===27){modal.trigger("reveal:close")}});
        function unlockModal(){locked=false}function lockModal(){locked=true}})}})(jQuery);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:49:01+00:00Added an answer on June 11, 2026 at 1:49 am

    An equivalent selector to $(“:button”) using valid CSS is $(“button, input[type=’button’]”).

    -from jquery.com

    Are you using an <input type="submit"> tag? if so, it won’t be picked up by the :button selector.

    Try this instead:

     $("button, input[type='button'], input[type='submit']")
         .live("click", function (e) { }
    

    Just a thought, maybe you aren’t using submit tags though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im new to asp.net mvc. I'm trying add new model class but it got
I have a modal window, simulation JavaScript confirm box. Depending on button click i.e.,
I am trying to add a modal window option to my webpage. It is
I'm trying to add a new ADO.Net Entity Data Model to an MVC project
Trying to add a blank sample app for a rails tutorial to GitHub, but
I am trying to open an preview.aspx page in a seperate window from INSIDE
I am trying to add an email service to a site. I have a
I am trying to create a modal window for my application, but unfortunately I
I'm trying to present a Modal View Controller when the app enters in foreground..
EDIT: Problem was fixed in .NET 4.0. I have been trying to bind a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.