0
出於某種原因,附加數據單擊事件不工作,有什麼奇怪的,如果我對作品的用戶名點擊,但刪除以及顯示註釋按鈕沒有真正jQuery的AJAX授權後經過附加數據
附加數據當我點擊這些2
<a href="#" data-id="'. $this->post->id .'" class="delete-post"><i class="trash icon"></i>Törlés</a>
<a href="#" data-id="'. $this->post->id .'" class="comment-post"><i class="chat icon"></i>Hozzászólás (<span class="comment-count">0</span>)</a>
JQ
<div class="event">
<div class="label">
'.HTML::image($this->post->user->profileImageMini(), "").'
</div>
<div class="content">
<div class="date">
'.$this->post->created_at->diffForHumans().'
</div>
<div class="summary">
<a href="'. url($this->post->user->username) .'">
'. $this->post->user->name() .'
<small>'. '@'.$this->post->user->username .'</small>
</a>
</div>
<div class="extra text">
'.linkify_post($this->post->body).'
</div>
<div class="feed-options pull-right">
<a href="#" data-id="'. $this->post->id .'" class="delete-post"><i class="trash icon"></i>Törlés</a>
<span>-</span>
<a href="#" data-id="'. $this->post->id .'" class="comment-post"><i class="chat icon"></i>Hozzászólás (<span class="comment-count">0</span>)</a>
</div>
</div>
</div>'
Click事件不工作uery
$('.comment-post').on('click', function(){
var post = $(this).data('id');
$('#'+post).find('.ui.comments').toggle();
return false;
});
$('.delete-post').on('click', function(){
var post = $(this).data('id');
$.post('posts/delete', { postId: post }, function(){
$('#feed-wrapper #'+post+'').toggle("highlight");
})
return false;
});
$('#feed-form').on('submit', function(){
var formData = $(this).serialize();
$.ajax({
url: this.action,
type: this.method,
data: formData,
dataType: "json",
context: this,
beforeSend: function()
{
$(this).find('#send-stream').addClass('disabled');
$('.feed-loader').show();
},
success: function(data)
{
if (data.status == 'success') {
$(this).find('textarea').val('');
$('.countdown').text('250');
$('#feed-wrapper').prepend(data.body)
}
},
complete: function()
{
$('.feed-loader').hide();
}
});
return false;
});
試過代表,但沒有不工作,當數據被追加後,我刷新頁面的作品,但阿賈克斯後提交無。
任何暗示我愚蠢的地方?
嘗試過這種方法,不工作 – 2014-09-05 07:37:30