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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:20:19+00:00 2026-05-30T19:20:19+00:00

I created a custom helper for managing my radio buttons. It allows me to

  • 0

I created a custom helper for managing my radio buttons. It allows me to click on the label to select the corresponding radio button. It works but I found a situation where it didn’t work anymore.

Here is the scenario: the first time the jQuery UI dialog is loaded, I’m able to click on a label to select the corresponding radio button. I must say that my radio buttons are loaded into a form in a jQuery dialog.

The problem occurred if I close then reopen the jQuery dialog, then my labels are no more associated with the radio buttons (but everything works pretty well except that point).

enter image description here

Here is the code of my helper:

    public static MvcHtmlString RadioButtonFor2<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object value, object labelText)
    {
        object currentValue = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData).Model;
        string nameX = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData).DisplayName;
        string uniqueId = ModelMetadata.FromLambdaExpression(expression, htmlHelper.ViewData).DisplayName + "_" + value;

        TagBuilder htmlRadio = new TagBuilder("input");
        htmlRadio.MergeAttribute("type", "radio");
        htmlRadio.MergeAttribute("id", uniqueId);
        htmlRadio.MergeAttribute("name", nameX);
        htmlRadio.MergeAttribute("value", (string)value);

        if (currentValue != null && value.ToString() == currentValue.ToString()) htmlRadio.MergeAttribute("checked", "checked");

        TagBuilder htmlLabel = new TagBuilder("label");
        htmlLabel.MergeAttribute("for", uniqueId);
        htmlLabel.SetInnerText((string)labelText);

        return MvcHtmlString.Create(htmlRadio.ToString(TagRenderMode.SelfClosing) + htmlLabel.ToString());
    }

This code produces html code like this:

<input name="ADR" id="ADR_Yes" type="radio" value="Yes"/>
<label for="ADR_Yes">Oui</label>

As you can see label is correctly associated with input.

Do someone have any idea why it works only the first time the jQuery UI dialod is loaded?

I’m a bit lost.

Thanks.

  • 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-30T19:20:21+00:00Added an answer on May 30, 2026 at 7:20 pm

    I finally found a solution:

    Whenever I need to close the jquery dialog, I must destroy it completely from the DOM.

    I replaced this line:

    $(this).dialog('close');
    

    With the following:

    $(this).dialog('destroy').remove();
    

    Maybe this can help someone else.

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

Sidebar

Related Questions

I've created a custom button helper. I pass text, url, css attributes, and everything
I created custom adapter for listview which contain text and images, on click of
I've created custom toggle slide animation. Its working fine as expected but its not
I created a custom UITableViewCell subclass which contains a button named testbtn . I
I created a custom helper class module which I'm calling thusly: $bench = Mage::helper('benchmark');
I created my custom Ajax.ActionLink helper (see below). I also write a summary above
I created Area called Admin. I have Custom Helper in the root folder called
I have created a custom razor helper in my MVC4 Web application that I
I am trying to implement auto closing custom helper. I have found how to
I have created a custom view helper and i'm calling it successfully. Only problem

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.