Live Query works within the "jQuery sandbox" for DOM Manipulation. The
function adddate uses regular DOM methods to insert the element. Simply
convert that method to use jQuery instead (bonus of shorter syntax too) and
it will work just fine.

function adddate() {
    alert('adding date');
    $('#target').html('<input class="date">');
};

--
Brandon Aaron

On 9/20/07, leon14850 <[EMAIL PROTECTED]> wrote:
>
>
> Hi, all! I'm experiencing a strange problem with Live Query. When I
> add elements to the DOM, they aren't picked up until I click a pre-
> existing element with a jQuery behavior. The key parts of my sample
> code are:
>
>                 <script type="text/javascript" src="/intranet/js/
> jquery.livequery.js"></script>
>                 <script type="text/javascript" src="/intranet/js/jquery-
> calendar.js"></script>
>                 <style type="text/css">@import url(/intranet/css/jquery-
> calendar.css);</style>
>
>                 <script type="text/javascript">
> $('input.date').livequery(function(){
>                         alert('found new input.date');
>                         $(this).calendar(
>                                 {
>                                         dateFormat:"MDY/",
>                                         speed:"",
>                                         yearRange:"2000:2020"
>                                 }
>                         );
>                 });
>
>                         function adddate() {
>                                 alert('adding date');
>                                 document.getElementById
> ('target').innerHTML='<input
> class="date">';
>                         }
>                 </script>
>
>                 <input class="date">
>                 <input type="button" onclick="adddate();" value="add
> date">
>                 <div id="target"></div>
>
> In order to get the calendar behavior to happen on the JS-added input
> field, I have to click in the original input field to see that
> calendar. Then I get the "found new input.date" message.
>
> Can anyone point out if I'm doing something really silly, or is there
> actually a bug in Live Query? I tested this in FF2/Mac and MSIE 7.
>
>

Reply via email to