Sunday 13 January 2013

How can we used date picker for every records(input box) that create when we clone.

How can we used date picker for every records(input box) that create when we clone.

For more explanation I give an example.

I have create one date picker that will create a calendar and through that we can select the date.
To use that date picker I have to assign it with text box id or class in ready function of jquery.

But when I cloned, It doesn't reflect the cloning text box.

How can I solve this problem?

2 comments:

  1. Whenever you are cloning a textbox, by default, it won't clone all the events attached to it.

    jQuery allows you to clone an element with all event handlers. However, in this case, if you're cloning element with its event handlers, click on cloned node will open but when you select a value, it will be reflected in original text box.

    To understand this better, check this example: http://jsfiddle.net/NELfV/1/

    So, for your case, you have to bind a new datepicker with your cloned textbox. In your code which clones the textbox, assign a new datepicker to the date field and it will work.

    ReplyDelete
  2. Thank You!

    I done it and now its working properly.

    Actually, When I clone in JavaScript, I assign the date picker to the text box before cloning so that it doesn't reflect anything just a text box. Now I assign a date picker after cloning and now it works.

    And In Jquery, when I clone It clone all the the events attached to it and in that by default the text box already contained that class which is assign by date picker. In this case I have remove the existing class which is assign by date picker. And then assign it again.

    ReplyDelete