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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:31:52+00:00 2026-06-16T05:31:52+00:00

I’m developing an MVC4 mobile app using Visual Studio 2012 with jQuery Mobile. I

  • 0

I’m developing an MVC4 mobile app using Visual Studio 2012 with jQuery Mobile. I need to remember the state of checkboxes and radio buttons so I store their value in a cookie. When I come back to the page in the pageinit event I set the values but the controls never update visually. Using Firebug with the page rendering as mobile I can see that the values changed correctly. I’ve tried calling checkboxradio(‘refresh’) on the element like this:

$('#btnCompany').prop('checked', true)checkboxradio('refresh');

but I always get an error saying checkboxradio is undefined and not supported. I know the control is a radio button. To try and work around the problem I extracted the code in jQuery Mobile to refresh a radio button and checkbox which I call and again I can clearly see in Firebug that not only is the input checked correctly but the label classes have changed appropriately. However, visually nothing changes, they look like they did originally. Am I missing something? Why am I getting an error saying checkboxradio is not supported even when I call this in the pageinit event:

$("input[type='radio']").checkboxradio("refresh");

I’ve tried refreshing by hiding then showing the containing div but that failed. Nothing I’ve tried refreshes the controls visually. Any and all help would be greatly appreciated!!!

Here are the functions I’m calling to refresh the page bypassing checkboxradio. Here is the function I call to try and work around the problem:

function SetSearchFormState() {
if ($.cookie('cmdSearchForm') != null) {

    //$('#searchParamsDiv').hide();

    var formData = JSON.parse($.cookie('cmdSearchForm'));

    $('#SearchText').val(formData.SearchText);        

    // Set all search buttons to not selected.       
    $('.searchBtn').each(function () {
        $(this).prop('checked', false);
        RefreshCheckboxRadio(this, false);
    });

    // Set the appropriate search button selected.
    $('#hidSearch').val(formData.hidSearch);
    switch (formData.hidSearch) {
        case 'Opportunity':
            $('#btnOpportunity').prop('checked', true);
            RefreshCheckboxRadio($('#btnOpportunity'), true);
            break;
        case 'Company':
            $('#btnCompany').prop('checked', true);
            RefreshCheckboxRadio($('#btnCompany'), true);
            break;            
        case 'Contact':
            $('#btnContact').prop('checked', true);
            RefreshCheckboxRadio($('#btnContact'), true);
            break;
    }

    // Set all status buttons to not selected.
    $('.statusBtn').each(function () {
        $(this).prop('checked', false);
        RefreshCheckboxRadio(this, false);
    });        

    // Set the appropriate status button selected.
    $('#hidStatus').val(formData.hidStatus);
    switch (formData.hidStatus) {
        case 'Lead':
            $('#btnLead').prop('checked', true);
            RefreshCheckboxRadio($('#btnLead'), true);
            break;
        case 'Prospect':
            $('#btnProspect').prop('checked', true);
            RefreshCheckboxRadio($('#btnProspect'), true);
            break;
        case 'Customer':
            $('#btnCustomer').prop('checked', true);
            RefreshCheckboxRadio($('#btnCustomer'), true);
            break;
    }        

    // Set the appropriate include button selected.
    $('#hidAllUsers').val(formData.hidAllUsers);
    $('#btnAllUsers').prop('checked', false);
    RefreshCheckboxRadio($('#btnAllUsers'), false);
    if (formData.hidAllUsers == 'True') {
        $('#btnAllUsers').prop('checked', true);
        RefreshCheckboxRadio($('#btnAllUsers'), true);
    }

    $('#hidDead').val(formData.hidDead);
    $('#btnDead').prop('checked', false);
    RefreshCheckboxRadio($('#btnDead'), false);
    if (formData.hidDead == 'True') {
        $('#btnDead').prop('checked', true);
        RefreshCheckboxRadio($('#btnDead'), true);
    }

    //$('#searchParamsDiv').show();
    $("input[type='radio']").checkboxradio("refresh");
    $("input[type='checkbox']").checkboxradio("refresh");
}
};

And here is the function that I extracted out of jQuery mobile’s checkboxradio refresh method:

function RefreshCheckboxRadio(control, value) {
if ($(control).is(':radio')) {
    var parent = $(control).parent('div');        
    var controlId = $(control).attr('id');
    var label = $(parent).find("label[for='" + controlId + "']");
    var icon = $(label).find(".ui-icon");
    //$(parent).hide();
    if (value == false) {            
        $(control).removeAttr('checked');
        $(label).removeClass('ui-radio-on ui-button-active').addClass('ui-radio-off');
        $(icon).removeClass('ui-icon-radio-on').addClass('ui-icon-radio-off');
    } else if (value == true) {            
        $(control).attr('checked', 'checked');
        $(label).addClass('ui-radio-on ui-button-active').removeClass('ui-radio-off');
        $(icon).addClass('ui-icon-radio-on').removeClass('ui-icon-radio-off');
    }
    //$(parent).show();
} else if ($(control).is(':checkbox')) {
    var parent = $(control).parent('div');       
    var controlId = $(control).attr('id');
    var label = $(parent).find("label[for='" + controlId + "']");
    var icon = $(label).find(".ui-icon");
    //$(parent).hide();
    if (value == false) {
        $(control).removeAttr('checked');
        $(label).removeClass('ui-checkbox-on ui-button-active').addClass('ui-checkbox-off');
        $(icon).removeClass('ui-icon-checkbox-on').addClass('ui-icon-checkbox-off');
    } else if (value == true) {
        $(control).attr('checked', 'checked');
        $(label).addClass('ui-checkbox-on ui-button-active').removeClass('ui-checkbox-off');
        $(icon).addClass('ui-icon-checkbox-on').removeClass('ui-icon-checkbox-off');
    }
   // $(parent).show();
}
};

After this code is run I can see the values are correct and exactly as they would be if checkboxradio(‘refresh’) had been called. So even though I can’t get checkboxradio to work, performing the work manually should work and in fact does when I view the changes in Firebug yet the controls still don’t change their appearance.

  • 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-16T05:31:53+00:00Added an answer on June 16, 2026 at 5:31 am

    After much experimentation I finally threw out this code, disabled Ajax in jQuery Mobile, then handled all of the Ajax manually. I could write a book about what I learned about developing jQuery Mobile apps with MVC4 and probably help many folks out there but alas I don’t have the time nor do I get paid for doing so, sorry. I can only hope that someday somebody documents how to do things the right way so there’s a single source people can turn to instead of having to spend hours searching for bits and pieces here and there.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
I am reading a book about Javascript and jQuery and using one of the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
In my XML file chapters tag has more chapter tag.i need to display chapters

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.