我的application / view / userlist.php
中有以下代码<script type="text/javascript">
$(document).ready(function(){
$('.edit-row').live('click',function(){
var me = $(this);
var editModal = $('#myModalEdit');
editModal.find('#userFullName').val(me.attr('data-userFullName'));
editModal.find('#userID').val(me.attr('data-userID'));
editModal.find('#userName').val(me.attr('data-userName'));
editModal.find('#userPass').val(me.attr('data-userPass'));
editModal.find('#userEmail').val(me.attr('data-userEmail'));
$('#myModalEdit').modal('show');
});
});
</script>
<div class="modal fade" id="myModalEdit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Edit System User <label id="userFullName"></label></h4>
</div>
<form role="form" id="userForm" action="<?php echo base_url().'admin/updateUser'; ?>" method= "POST">
<!-- #myModalEdit codes here-->
</form>
<!-- some html codes -->
<a class="edit-row" href="javascript:"
data-userID="<?php echo $row->userID; ?>"
data-userFullName="<?php echo $row->userFullName; ?>"
data-userName="<?php echo $row->userName; ?>"
data-userEmail="<?php echo $row->userEmail; ?>"
data-userPass="<?php echo $row->userPass; ?>"
>
<button type="button" data-hover="tooltip" title="Edit User <?php echo $row->userName; ?>" class="btn btn-default">
<i class="fa fa-pencil"></i>
</button>
</a>
我收到了错误
未捕获的TypeError:$(...)。live不是函数
这是什么意思?
答案 0 :(得分:1)
用户.on()
代替.live()
试
$(parentDiv).live('click', '.edit-row', function(){
// write you code here
});