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

  • Home
  • SEARCH
  • 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 4272584
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:35:50+00:00 2026-05-21T07:35:50+00:00

Just a simple question, but I cannot seem to bind a plugin function to

  • 0

Just a simple question, but I cannot seem to bind a plugin function to a live element that was cloned.

$('.add-another').live('click', function()
{
   var self = $(this);
   var clonedElement = self.parents('.row').clone();

   clonedElement.find('input.datepicker').bind('click', function()
   {
       $(this).datepick({ rangeSelect: true });
   });
});

I’m using this plugin (I’m not using jQueryUI nor it’s datepicker). So how can I bind a plugin function to a cloned/live element?

EDIT: Here’s a jsFiddle demo.

  • 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-21T07:35:51+00:00Added an answer on May 21, 2026 at 7:35 am

    You’re binding to an id (#add-another). The standard says that there can be only one element with a given ID at any time.

    So, this won’t really work as intended. Change the id to a class(i.e. the # to an .) and try again 🙂

    Another possible problem may be that the HTML simply doesn’t have the structure you expect it to and some of the queries are failing. We’d be able to debug that if you post the HTML structure 🙂

    Edit:
    You were binding to the “click” event, which was actually wrong – you can create the datepicker at the same time you create the HTML element.

    Here’s the new code:

    $('.row input.datepicker').datepick({ rangeSelect: true });
    
    $('span.add-another').live('click', function()
    {
        var self = $(this);
        var clone = self.parents('.row').clone();
    
        $('input.datepicker', clone).datepick({ rangeSelect: true });
        $(clone).insertAfter(self.parents('.row')).hide().slideDown('fast');
    
        self.remove();
    });
    

    Also, I have bad news for you – the datepicker plugin is broken 🙂
    The datepicker itself seems to only be able to show one datepicker on a page.
    You should either research how to show several, or just use jQueryUI.

    As you can see, here only the original object has a datepicker: http://jsfiddle.net/qZn8d/7/
    And here only the first added object has a datepicker: http://jsfiddle.net/qZn8d/6/

    So, yeah, the plugin is broken, sorry 🙂

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

Sidebar

Related Questions

This may sound like a simple question, but I just cannot seem to find
I have a relatively simple question that I cannot seem to find the answer
Just a quick simple question that I can not seem to find an answer
This is a very simple question, but I can't seem to find something about
Hopefully have a simple question here but I cannot for the life of me
I wrote the following jQuery plugin that is basically just a simple notification system
I just have one simple question about XSS attack. I know that you can
Simple question, hopefully an easy way and just want to verify I'm doing it
Simple question. I use Visual studio and I've just installed subversion, how can i
I've built a simple application that applies grid-lines to an image or just simple

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.