2
Good afternoon, everyone.
Once again I come to you about a problem I have. I need to use the syntax below in a modal.
$("#divConsulta").clone().appendTo($("#formFruta"));
In the row below when clicking, I open my modal with the data form to update:
<a href="<c:url value="edita?cod=${fruta.cod}"/>" class="btn btn-success btn-xs" data-toggle="modal" data-target="#update-modal" title="Editar"><span class="glyphicon glyphicon-edit"></span></a>
The thing is, I don’t know how to do this:
clone(). appendTo
for my modal.
In short, I don’t know if I’m right, I need to pass the content of a div that is on a page, that when clicked the button to open modal, the content of #divConsulta goes to #formEnjoy that it is in a Bootstrap modal.
I hope I’ve been clear, because I’ve been trying this for hours.
Grateful
I believe you do not need to use $('#formFruta') to identify the element, just use ('#formFruta'). It would look like this: $("#divConsult"). clone(). appendTo("#formFruta");
– Ricardo
@Ricardo reading the documentation (http://api.jquery.com/appendto/) the method
appendTo
accepts as parameter: selector, element, HTML string, array of elements or jQuery object, hence the$('#formFruta')
is a valid value. The problem must be another.– Filipe Moraes
The element with the ID
formFruta
is there at the time the append is run? Is there an error? Take a look at the browser console to see if any Exception is fired.– Filipe Moraes