There are a bunch of problems with your code. For one thing, there are several textboxes with the id's starttime
and endtime
, whereas an id should occur only once in the document.
What's causing your problem is the fact that upon the click of any radiobutton, the timepicker
will be initialized for all elements matching the $("#starttime, #endtime")
selector. That will mean the first div
(which is visible), works OK, and the select fields get positioned alright, but for subsequent div
's, it is being positioned at a time when the div they're associated with are hidden, and as such, their positions cannot be calculated.
I'd consider changing the code so that your div
's have id's called "recur1", "recur2", etc, rather than "daily" and "weekly", and also give al of them a class, "recur". Then you'll be able to remove all your if-statements and just do:
$('.recur').hide();
$('#recur'+recurType).show();
It'll also enable you to do this, which will solve your problem:
$('#recur'+recurType).find("#starttime, #endtime").timePicker({ ... });