내가 sammy.js jQuery를 문서로 요청을 바인딩 대상 속성을 확인하여sammyjs에서 이벤트를 시작한 요소를 어떻게 찾을 수 있습니까?
this.get('#!/testing', function(context) {
//how I can get the event sender?
});
내가 sammy.js jQuery를 문서로 요청을 바인딩 대상 속성을 확인하여sammyjs에서 이벤트를 시작한 요소를 어떻게 찾을 수 있습니까?
this.get('#!/testing', function(context) {
//how I can get the event sender?
});
으로 jQuery를
$('a').click(function() {
console.log($(this)); //the event sender and can be 'a' or 'ul>li>a'
});
을 사용하여 다음과 같은 마크 업을
<ul class="app-nav">
<li><a href="#!/testing">Link to testing route</a>
</ul>
...
<a href="#!/testing">Other link to testing route</a>
있다고 가정
$(document).on('click', function(e){
var sender = e.target; // <-- Your event initiator
});
설명서에 따라 Event Context이 원하는 것 같습니다.
this.target
이 컨텍스트를 보유하는 이벤트에 기인하는 DOM 소자. post, put 및 del 경로의 경우 경로를 트리거 한 양식 요소입니다.
게시 요청의 경우 제출 된 양식에서 일련 번호가 지정된 개체를 가져올 수 있습니다.
this.post('#:id', function() {
// this.target is the DOM form element that triggered the route
console.log($(this.target).serialize());
});