동적으로 추가 된 요소 (JSON 함수 내부)에 컨트롤을 할당하는 데 문제가 있습니다.Jquery - getJSON에서 동적으로 추가 된 컨트롤 추가
코드가 제대로 작동하지만 $ ('div.prnt')를 추가 할 때. append ("hello"); JSON 안에 $ ("div.text")를 할당하지 않습니다. draggable(); 그것에. JSON 함수를 사용하지 않고 $ ('div.prnt') 만 사용하고 있습니다. append ("hello"); 그것은 곧바로 작동합니다.
나는 드래그 가능한 컨트롤이 호출되기 전에 JSON 함수가 요소가 추가되는 것을 멈추고 있다고 생각합니다.
<style>
div.prnt div.test
{
border: 1px solid #000;
width: 200px;
height: 200px;
}
</style>
<script type="text/javascript">
$(document).ready(function()
{
var serviceurl = "WebServices/BusinessCardStudio.svc/gettextobjects/3457/17/17/1064/709/600/399";
$.getJSON
(
serviceurl,
function (data)
{
$.each(data, function (i, item)
{
$('div.prnt').append("<div class='object text'>hello</div>");
});
}
);
$("div.text").draggable();
});
</script>
<div class="prnt">
</div>
누구든지이 문제를 해결할 방법을 알고 있습니까? 사전