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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:25:05+00:00 2026-06-11T09:25:05+00:00

I would really appreciate if somebody could help me. I am trying to dynamically

  • 0

I would really appreciate if somebody could help me. I am trying to dynamically build a collapsible block with jQuery mobile 1.2 Beta (using jQuery 1.7.1).

Now I have the problem that I want to have an button inside a collapsible header and all works fine but when I click on the button the click event I set on it is not fired but instead the block gets uncollapsed or collapsed.

$('#main').append('<div data-role="collapsible" data-theme="c" data-content-theme="c" id="pflicht_' 
+ identifier + '" pflichtID="' + val.guid + '">' +
'<h3 style="white-space: normal;" id="inner_header_' + identifier + '">' 
+ header + ': ' + val.pflichtBezeichnung + ' (' + val.Intervall + ' - ' + val.IntModus + ') ' 
+ val.pflichtNummer + '.' + val.pflichtZusatz + 
'<button type="button" data-inline="true" id="ok" pflichtID="' 
+ val.guid + '" identifier="' + identifier + '" >Ok</button></h3>' +
'</div>'

$("#ok").live('click', function () {
                  alert("ok");
              });

What do I have to do to get the click event of the button?

Thanks 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-11T09:25:07+00:00Added an answer on June 11, 2026 at 9:25 am

    First off you should realize that .live has been deprecated in favor of on.

    That said to understand what’s going on here you need to understand how event delegation works in general and live in particular, when you use event delegation you bind your event to a higher level in the DOM (some parent element) and then because events bubble up you check the originating event to see if it matches the specified selector.

    The .live method works by binding the event to the document (so it is always bound to a parent element) and then when an event bubbles up to the document it checks to see if it matches the selector specified. The issue in your case is that something (probably the collapisple header) is swallowing up the click event so that it never reaches the document.

    The solution is pretty simple, either bind directly to the button, or delegate to a lower level in the DOM, somewhere where your event will reach.

    For example

    $('#inner_header_' + identifier).on('click', '#ok', function(e) {
        alert('ok');
    });
    

    If you don’t want the header to expand and collapse when you click the button, just stop the event from bubbling up further, which you can do using the stopPropagation() method

    For example

    $('#inner_header_' + identifier).on('click', '#ok', function(e) {
        alert('ok');
        e.stopPropagation()
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would really appreciate it, if somebody could help me out with my regular
I would really appreciate any jquery expert help as a method I've used previously,
I would really appreciate it if some of you could help optimize my tables,
I would really appreciate if somebody could tell me why compilation of this program:
I would really appreciate your help with an installation error. I've been trying to
I would really appreciate if you could shed light on this problem. I have
I would really appreciate any help with the following problem: I need to be
Ok I give up and would really appreciate it if you guys could cast
I'm very new to C++ and would really appreciate any and all help. I
i would really appreciate any help. I would like to convert this list [[{id1,1},{id2,2},{id3,3},{id4,4}],[{id1,5},{id2,6},{id3,7},{id4,8}],[...]]

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.