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

  • SEARCH
  • Home
  • 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 7020217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:17:23+00:00 2026-05-27T23:17:23+00:00

I have a partial view which is returned via an Ajax call with a

  • 0

I have a partial view which is returned via an Ajax call with a dataType of html – inside this html is an anchor tag with an id, which I am wiring up a click event using jQuery’s .on() API and version 1.7.1 of the framework.

For brevity’s sake, imagine the partial view is as follows:

<div id="container" class="modal-dialog">
    <h1>Heading</h1>
    <a id="thelink" href="#">
        <img src="<%:Url.Content("~/Path/To/Image.jpg")%>" /></a>
</div>

..and via a standard $.ajax POST to an MVC controller action which returns the above as a partial view result, which I intercept and spit into the modal dialog.

The event code that I’m attempting to hook up looks as follows:

$(function () {
    $("#thelink").on("click", function (e) {
        e.preventDefault();
        $("#jquery-ui-dialog-box").dialog("close");
    });
});

Now, if I switch the on() to live() – everything works as expected. With the code above though in IE8 (IE8 Standards mode) the event does not fire – breakpoints are not hit, the jQuery UI modal doesn’t close as per the example above. With a live() call though, it all works as expected.

This is the first and only time I’ve ever seen a differential between the behaviour of on() and the deprecated or ‘rolled up’ event binding API (delegate, live, bind)

I have no issues with reverting to using live() or delegate() but would like to understand why this is occurring, if that is possible!

Regards
SB

  • 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-05-27T23:17:24+00:00Added an answer on May 27, 2026 at 11:17 pm

    $(foo).live(type, handler) is equivalent to $(document).on(type, foo, handler), so try the following instead;

    $(function () {
        $(document).on("click", '#thelink', function (e) {
            e.preventDefault();
            $("#jquery-ui-dialog-box").dialog("close");
        });
    });
    

    The signature of live() is confusing; you’re not actually binding a handler to the selected elements, but to the document element, which listens for an event to be fired on an element which matches the given selector ( How does jQuery .live() work? ).

    $(foo).live(type, handler) is equivalent to $(document).delegate(foo, type, handler);

    For future reference, $(foo).delegate(selector, type, handler) can be converted to on() just by swapping the first and second parameters; on() expects the event type first, then the (optional) selector.

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

Sidebar

Related Questions

i have view which looks something like this : <% using (Ajax.BeginForm(new AjaxOptions {
Suppose that I have this partial view: Your name is <strong>@firstName @lastName</strong> which is
I have a partial view which can either be requested via an Action (Action2
I have a view in which I am attempting to do an ajax call
I have this in my partial view: <tr> <% for (int currentDay = 0;
in a partial view I have the following: <%Html.RenderAction(MVC.User.GetComments(Model.UserGroupName)); %> can I render a
I have an ASP.NET MVC Partial View that contains a Html.TextBox that is configured
I have a partial view which has dual list boxes and four buttons; exactly
I am using ASP.Net MVC. I have a partial view which has a form
I have a partial view which renders a table. On page load, I am

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.