Friday, July 10, 2009

jQuery DatePicker Gotcha - Don't call it twice

I spent several hours tracking down an issue with the jQuery date picker control today and discovered a bit of a gotcha. I was displaying a simple table, with dynamically created editable rows that contained date controls. When the table was first created, the date picker in each row worked fine. But after hiding and updating the table the date pickers did not work.

I thought initially that it was an issue with z-indexing and that the date picker was being displayed, just behind the dialog containing the table. Working on this assumption, I spent a while fighting with z-index settings in the jquery-ui css file as suggested in various online postings.

After looking at my code though, I realized that I was running this code after updating my table to enable the date picker on new rows:


   1:  this._editor().find('.DateEntry').datepicker(opt);


The problem was that I wasn't deleting all the rows in my table and recreating, I was only updating a subset of rows and adding a few new ones. Thus I was calling the date picker function on an element that had already been enabled as a date picker. This prevented any elements from being made into date pickers.

Moral of the story, never call datepicker() twice on the same element. Bad mojo.

3 comments:

kaceeradcliffe said...

Free Spins and Bonus | Casinoowed.com
Play more than 140 games with a FREE $20 free spins bonus! No need to pay anything! Get free spins and up 메리트카지노 to $1000 casino bonus for new players! Rating: 4.5 카지노사이트 · ‎Review by CasinoWow

fabyannahabersham said...

You can find all of our guides to learn how to to|learn to} play and win at any on line casino recreation. Look on your preferred recreation 클레오카지노 and study all about it so you can start playing in} like a pro. There are some variants that may be} played with as little as 10p per spin. If you might be} more centered on inserting minimal stakes during a recreation, you would possibly want to set your account with a limit setting, so you don't go overspending on video games.

maerynpadin said...

However, the mechanics of early machines have been outmoded by random number turbines, 더온카지노 and most are now are|are actually} operated utilizing buttons and touchscreens. Bet More on the Payline – The most important a part of} this strategy is to wager more cash on the pay line. This is the line the place you win, so you need as much on this line. – The most important a part of} this strategy is to wager more cash on the pay line. Keep an Eye on Special Features – A lot of slots video games have special options that you should use|you need to use} to your benefit.