저는 jQuery.just를 처음 접하고 3 주 동안 학습하고 사용합니다. 물건 정리를 위해 수업을 작성했습니다. 두 개 이상의 이벤트가있는 내 메서드를 호출하지만 두 번째 이벤트가 트리거되는 동안 이벤트가 작동하지 않습니다. 선택기에 문제가 없습니다. 내 수업에는 뭔가 빠져 있다고 생각합니다. 나는 모른다. 도와주세요! 여기에 코드 조각입니다 :Jquery : 두 번째 호출에서 클래스가 작동하지 않습니다.
$("#btnPersonalNext, #btnDocListBack, #pDocList").livequery('click',function()
{
var docListContent = 'loadDocumentList.php';
$("#contentpaper").addContent(
{
_tag:'div',
_id: 'contentDocList',
_class: 'content',
_content: docListContent,
_heading: 'Document List'
});
//store personal info in session:
});
addContent()
는 기능입니다. #btnPersonalNext
을 클릭하면이 기능이 작동하지만 #btnDocListBack
의 경우 더 이상 사용하지 않습니다.
여기 내 수업은 (jquery.content.js
)입니다. 그게 무슨 특정 _tag
에 _id
와로드 HTML입니다.
(function($)
{
$.fn.addContent = function(options)
{
var defaults = {
_tag: 'div',
_id: '',
_class: '',
_content: '',
_heading: '',
_clearExisting:'yes',
_insertAfterID:'',
_deleteBeforeInsert:'no'
};
var options = $.extend(defaults, options);
return this.each(function()
{
obj = $(this);
if(options._clearExisting=='yes'){
obj.empty();
}
if(options._deleteBeforeInsert =='yes'){
$('#'+options._id).remove();
}
var innerHtml = '<' + options._tag + ' id="' + options._id + '" class="' + options._class + '">';
if(options._heading!=''){
innerHtml += '<h2>' + options._heading + '</h2>';
}
if(/^[A-Za-z0-9]+\.php(\??([A-Za-z0-9]+=[A-Za-z0-9]+)(&[A-Za-z0-9]+=[A-Za-z0-9]+)*)?$/.test(options._content))
{//if .php
$.get(options._content,function(data)
{
//handle response from server here.
innerHtml += data;
innerHtml +='</' + options._tag + '>';
if(options._insertAfterID !=''){
$('#'+options._insertAfterID).after(innerHtml);
}
else{
obj.html(innerHtml);
}
});
} // PHP rule
else
{// .html
innerHtml += options._content;
innerHtml +='</' + options._tag + '>';
if(options._insertAfterID !=''){
$('#'+options._insertAfterID).after(innerHtml);
}
else{
obj.html(innerHtml);
}
} // HTML rule
}); // End of Returned Function
};// End of addContent definition
})(jQuery);
답을 기대하고, 정말 감사합니다!
<!-- JS --> <script type="text/javascript" src="jquery_plugins/jquery-1.2.6.js" ></script> <script type="text/javascript" src="jquery_plugins/jquery.livequery.js" ></script> <script type='text/javascript' src='jquery_plugins/jquery.simplemodal.js'></script> <script type="text/javascript" src="jquery_plugins/jquery.session.js"></script> <!--<script type="text/javascript" src="jquery_plugins/jquery-plugin-wrapinner.js"></script>--> <script type="text/javascript" src="jquery_plugins/jquery.content.js"></script> <script type="text/javascript" src="jquery_plugins/osra_main.js"></script> </head> <body> <div id="wrapper"> <div id="header"> <div id="headercontent">Please Enable JavaScript to Continue</div> </div> <div id="main"> <div id="sidebarpaper" class="left"> <!-- sidebar contents (class="sidebar")--> </div> <div id="contentpaper" class="right"> <!-- main contents (class="content")--> </div> <div id="modals" class="clear"> <!--modal pop-up window --> </div> </div> <div id="footer"><p></p></div> </div> </body> </html>
내가 ID #contentpaper
과 사업부에서 동적으로 내용을로드하고 있습니다 :
여기 내 DOM 구조입니다. , $("#btnID").livequery('click',function(){});
-bgreen1989
내가 말하는 버튼이 어디에 정의되어 있는지 알 수 없습니까? btnDocListBack btnPersonalNext 등? – krosenvold