동적 부모 내부 동적 부모에 관해서는 여전히 통계적으로 다르지 않습니다. 혼란스럽고 최악의 경우 어떻게 한 번 그리고 어떻게하면 원하는대로 조작 할 수 있는지 알 수 있습니다.동적 부모 자식 개체에서 이벤트를 처리하는 방법
당신의 정보는 Javascript와 Jquery에서 매우 새로워졌습니다. 그러나 누군가가 올바른 지침과 권리 구문을 제공한다면 따라 잡을 수 있습니다. 나는 그 코드에서 내가 더 많이 배울 수 있고 이해할 수있는 깨끗한 코드를 좋아한다.
하자 내가 그것을 firebugs에 동일합니다이 구조 HTML을 갖고 있다고 : -
<div name="div0" class="div0">
<input name="txt0" class="txt0">
<br/><br/>
<div name="div1[]" class="divL1">
<button class="btn1"></button>
<button class="btn2"></button>
<input name="txtL1_a[]" class="cLtxt1">
<input name="txtL1_b[]" class="cLtxt1">
<br/><br/>
<div name="div2[]" class="divL2">
<div id="ui-widget">
<input name="txtL2_a[]" class="cLtxt2 autosuggest">
</div>
<input name="txtL2_b[]" class="cLtxt2">
</div>
<br/><br/>
<div name="div1[]" class="divL1">
<button class="btn1"></button>
<button class="btn2"></button>
<input name="txtL1_a[]" class="cLtxt1">
<input name="txtL1_b[]" class="cLtxt1">
<br/><br/>
<div name="div2[]" class="divL2">
<div id="ui-widget">
<input name="txtL2_a[]" class="cLtxt2 autosuggest">
</div>
<input name="txtL2_b[]" class="cLtxt2">
</div>
</div>
<br/><br/>
는 사실 내 머리에 질문을 많이 가지고 있지만, 내가 먼저 몇 가지 질문을 물어 보자.
1 내가 실행할 .autosuggest가이 전에 때문에 일반적인 양식에 나를 위해 복잡 어디 실행을 관리 할 수 있지만, .autosuggest 내부 동적 부모 DIV 및 동적 입력에있는 때이 값을 얻을 수 있으며, 자동 완성 표시.
주어진 id "txtL2_a []"함수에 의해 SearchText는 성능 자동 완성을 수행 할 수 없으며 어떤 인덱스가이를 수행하는지 알지 못합니다. 하자 내가
<input name="txtL2_a[]" class="cLtxt2 autosuggest"> //index :1
을 채우기 말할 때 자동으로 내부
<input name="txtL2_b[]" class="cLtxt2"> 'Index 1
가치 -
function SearchText() {
$(".autosuggest").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "frmsetuptrip.aspx/GetAutoCompleteData",
minLength: 3,
data: "{'presearch':'" + document.getElementById('txtL2_a[]').value + "'}",
dataType: "json",
success: function (data) {
if ((data.d).length == 0) {
//$('#button9').show();
var result = [
{
label: 'No matches found',
value: response.term
}
];
response(result);
}
else {
response(data.d);
}
},
error: function (result) {
alert("Error");
}
});
}
});
}
2하자가
<div name="div1[]" class="divL1"> //index 1
에 내가 채워 몇 가지 자동 필요하다고
는 부모 색인 만 변경합니다.
3. 전에 다음이 의사 코드와 같은 특정 하위 기능 또는 작업을 갈 경우 내가 모든 이벤트를 잡아 그하여 정교한 수있는 하나 개의 함수 어쨌든있다 : -
$("div.div0").each(function (event) {
if (event=="keyup" on child=="divL1"+index[0]){
//detect more spesific which object are doing that
if (whoisdoing=="txtL1_a[]"+index[0] {
//then do action etc: fill up parent input
$("div0.txt0").val($(txtL1_a.index[0]).val());
}
if (whoisdoing=="txtL1_b[]"+index[0] {
//then do action etc: fill up childs input
$("div2[index[0]].txtL2_b[index[0]].val($(txtL1_b[index[0]]).val());
}
}
//event - keypress
//event - click
//and many more
});
I가 찾을 수없는이 위의 모든 문제에 관한 인터넷. 누구나 솔루션을 가지고 있거나 공유 기능을 개발했다면 쉽게 해결할 수 없다고 생각합니다.
어쨌든 내 질문을 읽고 회신 해 주셔서 감사합니다.
좋습니다.
html이 너무 유효하지 않습니다. 심지어 http://jsbeautifier.org/에서도 수정할 수 없습니다. – baao
정말 감사하고 싶다면 편집 후 HTML 구조를 다시 보도록하겠습니다. – ahadeveloper777