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 8552047
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:20:02+00:00 2026-06-11T14:20:02+00:00

I have an ASP.NET MVC 3.0 partial view which is render inside a jquery

  • 0

I have an ASP.NET MVC 3.0 partial view which is render inside a jquery ui dialog.
Inside this partial view I have some link which help me to display some more info.

@foreach (StatusType status in ViewBag.Status)
{
    <li>@status.StatusMessage<a href='#' status='@status.StatusCode'><img src=@Url.Content("~/Content/Images/information.png") alt="See detail"/></a></li>
}

I’ve bound those link with the click event:

$('a[status]').live('click', function (e) {
            if (e.preventDefault)
                e.preventDefault();
            else
                e.returnValue = false;
            var status = $(this).attr('status');
            alert('@Model.Code');
            ...});

What is happening is when I click the first time on the link it will display me the correct Code (let’s say 12). When I will load the partial view again for another code (66) it will display me two alert message, the first one with 12 (the old value I’ve clicked before) and the second one with 66.

The more partial view I will load the more value I will have in my alert.
I don’t understand why it is keeping me like an history of all the code I’ve clicked.

If somebody have any idea on this problem, it will be welcomed, it just driving me mad.

Thanks in advance.

UPDATED

The use of the on instead of the live works, but I still have an issue with the dialog.
I’ve change the code with the solution proposed:

            $('#StatusDiv').on('click', 'a[status]', function (e) {
            e.preventDefault();
            var status = $(this).attr('status');
            alert('@Model.Code');
            $('#StatusDialog').dialog({
                autoOpen: false,
                width: 800,
                resizable: true,
                title: 'Status Info',
                modal: true,
                open: function (event, ui) {
                    alert('@Model.Code');
                    $(this).load('@Url.Action("ViewStatusInfo")', { clientId: clientId, Code: '@Model.Code', status: status
                    });
                }
            });
            $('#StatusDialog').dialog('open');
        }); 

The first alert display the correct code, but the second alert inside the open function display the old one. On the second click it will work correctly but I don’t understand how it can pick the old value since the first display is correct…

Thanks again for your help.

  • 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-11T14:20:03+00:00Added an answer on June 11, 2026 at 2:20 pm

    First of all: do not use live in last versions of jquery.

    $('#list').on('click', '.status', function(e){
        e.preventDefault();
        alert(this.href);
    });
    

    Here we bind event to #list and when we will insert new links, everything will work.

    Demo: jsfiddle.net/wPSH2/

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

Sidebar

Related Questions

I have an asp.net mvc partial which contains a jquery ui tab control, marked
I am using ASP.Net MVC. I have a partial view which has a form
'm using ASP.NET MVC 3 with Razor views. I have a partial view which
Inside of an asp.net mvc partial view, I have an Ajax form that posts
I have an ASP.NET MVC Partial View that contains a Html.TextBox that is configured
I have a page which contains a html.RenderPartial, that renders an ASP.NET MVC partial
I have a ASP.NET MVC application which has a view populated with a model
I have an Asp.net MVC partial view that is used for searching. It does
In ASP.Net MVC I would like to render a different partial view depending on
I'm new to ASP.NET MVC and I have a partial view with a combo

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.