jQuery(document).ready(function(){ jQuery('#searchbox').val('My search
text');});
This doesn't work though, since the document ready event is fired
before the sikbox code loads and creates the #searchbox element.
Also, magic.js includes some logic that replaces the "Sikbox Live
Search" text on the blur and focus events.
My solution is to wait a delay of 2 seconds after the DOM has loaded,
which hopefully gives the sikbox JS time to load and create the
#searchbox element. I then unbind the original sikbox handlers, set my
text and bind my own handlers. If you guys can, it'd be ideal to add
another parameter to the URL for magic.js that can specify the text,
which then gets subbed in to your event handler logic, or even use a
JS variable for the search text that can be created if it doesn't yet
exist (i.e. uncustomized.) The delay hack I've created is lame, but I
don't know if there's an event I can use that gets triggered when
external JS has loaded.
Here's my code:
<script type="text/javascript">
jQuery(document).ready(function(){
setTimeout(function(){
jQuery("#searchbox").unbind('focus').unbind('blur');
jQuery("#searchbox").val("My Search Text");
jQuery("#searchbox").addClass("search_title");
jQuery("#searchbox").focus(function(){
if(jQuery("#searchbox").val()=="My Search Text"){
jQuery("#searchbox").removeClass("search_title");
jQuery(this).val("")}});
jQuery("#searchbox").blur(function(){
if(jQuery.trim(jQuery("#searchbox").val())==""){
jQuery("#searchbox").addClass("search_title");
jQuery("#searchbox").val("My Search Text")}});
},2000);
});
</script>
-e.
> >> >> >> This URLhttp://sikbox.com/#skinhassometipson how to create your