私のcodeigniterプロジェクトでイベントトリガーに問題があります。私は自分のページにテーブルを動的にロードしたい。このテーブルは、私のコントローラからajax呼び出しによって返されます。そして、私はそのテーブルのスパンでクリックイベントを引き起こしたいと思います。私はこれをさまざまな方法で試しましたが、うまくいきませんでした。私はここに私のコードを添付しています。解決策を見つけるのを手伝ってください。ajax応答要素のJQueryイベントをトリガーする
コントローラ:ビューで
$str = '<table>
<tr>
<td class="cost date" id="date_'.$request['SupplyID'].'">
<span class="editable" style="display: none;">
<input type="text" class="expiry" autocomplete="off" data-date-id="date_'.$request['SMSSupplyID'].'">
</span>
<span class="cnt" style="display: inline;">Choose</span>
</td>
</tr>
</table>';
echo $str;
スクリプト:
function loadmore()
{
var url;
url = '/SMS/SMS/loadMoreRequests';
$.ajax({
type: 'post',
url: url,
data: {
limit:val
},
success: function (response) { console.log(response);
$("#requestListTable").html(response);
val +=10;
}
});
}
$('.date').find('.cnt').on('click', function(){
console.log(1); // for testing
});
Iは、次の変更、ない使用
1)
$('.date').find('.cnt').live('click', function(){
console.log(1); // for testing
});
2)
0を試し$('.date').find('.cnt').click(function(){
console.log(1); // for testing
});
私の答えを試してくださいあなたの問題を解決することを願っています。 –