I’ve been struggling today for about an hour trying to get jQuery’s DatePicker working in Thickbox. There appeared to be some kind of conflict. I tried hacking up the Datepicker plugin file, changing the z-index of the CSS but nothing. The date picker wasn’t even being called.
Eventually I found that other people were having the same problem, and a comment by Kevin Luck (the author of DatePicker) flicked my brain into gear.
The problem was that I was initialising the datepicker on page load, not on the loading of the thickbox content.
For example, at the start of the page the Thickbox was going to be loaded in I had this:
<script type="text/javascript">
$(function(){// initiate date picker
$('.pick-date').datePicker();
});
</script>
</head>
However, I found that if I removed that from the head, and instead inserted it in the Thickbox content, e.g:
Just been working on a little something for a client involving Google Custom Search Engines.
The app we’re building uses 4 different search engines which are all specialised in a certain area. There is a central “Overview” page that gets the top results for the search from each of the search engines, plus there are normal links above the search box that, when clicked on should take the user directly to the Custom Search Engine results page for the string in the search box.
Sounds quite straightforward, but the links also save the current search (which may be different to the search box if the user has just entered a search into the box) so in this case, the old search needs to be stripped and the new search carried forward to the Custom Search Engine.
So it’s a little more tricky, but fortunately using jQuery and the URL Parser plugin by Mark Perkins I was able to cut out most of the tricky stuff.
Below is a little demo to illustrate the main part of the jQuery usage. Before you conduct a search, you should be able to click on the links to go and search Google for those keywords (jQuery, CakePHP, Ruby On Rails and No Search conducted). If you enter a string in the box and hit the “Search” button, you’ll go to Google and search for the string. However, if you enter a string in the search box but then click on a link, you’ll be taken to Google and search for the string.
This isn’t quite how it works on the client site, but is enough to show how the jQuery is being used.
<ulid="jQuerySearchExample"><li><ahref="http://www.google.co.uk/search"target="_blank">No Search</a></li><li><ahref="http://www.google.co.uk/search?q=jquery"target="_blank">jQuery</a></li><li><ahref="http://www.google.co.uk/search?q=CakePHP"target="_blank">CakePHP</a></li><li><ahref="http://www.google.co.uk/search?q=ruby+on+rails"target="_blank">Ruby On Rail</a></li></ul>
Search Google
<formaction="http://www.google.com/search"method="get"><inputid="jQuerySearchExampleInput"name="q"type="text"/><inputtype="submit"value="Search"/></form>