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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:09:40+00:00 2026-06-18T16:09:40+00:00

I have a web application which replaces content. This content has jquery ui check

  • 0

I have a web application which replaces content. This content has jquery ui check buttons. When I replace the content if a button already exists then don’t add it again:

if(!$('label[for=checkWeekM]').hasClass('ui-button'))
      $('.checkWeek').button();

If I push the button (its state is checked) and if I replace the content, the button starts locked until the same content is replaced again.

I use Backbone.js to replace the content

jsfiddle

How can I unlock the check button?

  • 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-18T16:09:41+00:00Added an answer on June 18, 2026 at 4:09 pm

    You are duplicating id attributes and that leads to bad HTML, bad HTML leads to frustration, frustration leads to anger, etc.

    You have this in your template that you have hidden inside a <div>:

    <input type="checkbox" class="checkWeek" id="checkWeekM" />
    <label for="checkWeekM">L</label>
    

    Then you insert that same HTML into your .content-central. Now you have two elements in your page with the same id attribute and two <label> elements pointing to them. When you add the jQuery-UI button wrapper, you end up with a slightly modified version of your <label> as the visible element for your checkbox; but, that <label> will be associated with two DOM elements through the for attribute and everything falls apart.

    The solution is to stop using a <div> to store your templates. If you use a <script> instead, the browser won’t parse the content as HTML and you won’t have duplicate id attributes. Something like this:

    <script id="template-central-home" type="text/x-template">
        <div data-template-name="">
            <input type="checkbox" class="checkWeek" id="checkWeekM" />
            <label for="checkWeekM">L</label>
        </div>
    </script>
    

    and then this to access the HTML:

    content.view = new ContentView({
        model: content,
        template: $('#template-' + template_name).html()
    });
    

    Demo: http://jsfiddle.net/ambiguous/qffsm/

    There are two quick lessons here:

    1. Having valid HTML is quite important.
    2. Don’t store templates in hidden <div>s, store them in <script>s with a type attribute other than text/html so that browser won’t try to interpret them as HTML.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Below is the content of source/destine XML(Web.Config) file, in which I have to replace
In Java web application (JSF), I have a Person form which has Add details
I have web application which we deployed in a production . We have separate
I have web application of which major part is javascript. I request images from
I have a web application which process the data collected from different client machines
I have a web application which uses the globalization values being passed from sql
I have a web application which needs to perform a file copy operation and
I have one web application which I have been working for some time.I am
I have a web application which contains both secure (SSL) and non-secure pages. A
I have a web application which is deployed by the means of Flask. I'm

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.