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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:58:18+00:00 2026-06-14T17:58:18+00:00

I’m creating a toggle button with this function: http://pastebin.com/gLkeB7pi Then I’m cloning this toggle

  • 0

I’m creating a toggle button with this function: http://pastebin.com/gLkeB7pi
Then I’m cloning this toggle button for a similar use – but not exactly the same. For that purpose, I need the same ‘click’ behaviour (that is, select/unselect & checkbox) but on the new cloned button.

So I’m trying this:
First, I modified createToggleButton: http://pastebin.com/tFZVafwE
Basically, I passed a checkbox parameter to the click handler by event.data and I modified the internal functions consequently, so that the new toggle checkbox is checked.
Then I did this:

var toggle = toggleButton.clone(true); //toggleButton is the toggle inside the div created with createToggleButton()
$(toggle).unbind('click');
$(toggle).bind('click',
    {chkbx: $(toggle).find('input[type=checkbox]')},
    function(evt){toggle.toggle(evt)}
);

But then, I can’t figure out at all what happens. On click, the new toggle slides up (?!) and the toggle.toggle function is not executed at all (I added a console.log).
So:

1) Am I thinking the right way to do what I wanna do?

2) Which code is actually executed on click and why?

  • 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-14T17:58:20+00:00Added an answer on June 14, 2026 at 5:58 pm

    Okay I got it. In case anyone stumble upon the same kind of problem:

    First – hacky and not tested – solution: if you want (or need) to use clone, first note that a JS Object method called toggle already exists. That was the one being called in my case, instead of the toggle.toggle I created. Moreover, the methods created in my createToggleButton function are not copied with clone. So, as David said, it’s better binding with $._data( toggleButton[0], 'events' ).click[0].handler;. Even then, in my case it won’t work because toggle.toggle calls toggle.active or toggle.deactive which both don’t exist in this context. So it’s necessary not to call any side function in the handler.

    Second solution (better): Don’t use clone. Reuse createToggleButton and manually add the needed HTML attributes (see jQuery: How to copy all the attributes of one element and apply them to another?).

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I want to construct a data frame in an Rcpp function, but when I
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

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.