this is how i would do it. i think you are having an issue with
assigning the html to a variable, relating to the scope of that
variable in the copy function.
I would just have it pull the data from the old div each time the
event was fired.

$(document).ready(function() {
     $('#whateverButtonElement').click(function() {
          var copyFrom = $('#old').html();
          //now copy to div
          $('#new').html(copyFrom);
     });
});

But you could just define the html outside of the event if the data
you are copying wont change:

$(document).ready(function() {

    var copyFrom = $('#old').html();

     $('#whateverButtonElement').click(function() {

          //now copy to div
          $('#new').html(copyFrom);
     });
});

Hope this helps


On Sep 11, 8:31 am, "Dave Maharaj" <[email protected]> wrote:
> Anyone know how to copy from 1 DIV to another?
>
> I have my Ajax action return info to my update DIV, then I need to call the
> js function to copy info from one DIV to another. The same call / Ajax
> request can be made over and over on the same page getting different data
> every time.
>
> I get it to work the first time then it stops working.
>
> Ideas?
>
> I have this on the bottom of the element that returns with the ajax data
>
> <script type="text/javascript">
>
> $(function(){
>
>   var str = $('#new').html();
>
> $('#old').html(str);
>
> $('#new).remove( function() {
>
>              var str = null;
>
>             });        
>
> });
>
> </script>  

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to