javascript - JQuery Datatables. Can't get JQuery function to work after AJAX load -


here screencast of issue make clearer....

http://screencast.com/t/kxd8u1oa0yu6

this first project i'm trying head round ajax running few stumbling blocks.

i have datatable loads user details json output via ajax.

there "deactivate" button deactivates user account.

i have applied popconfirm id each row...

            <script type="text/javascript">                 $(document).ready(function() {                     $('#user_list').datatable( {                         statesave: true,                         "pagelength": 20,                         "ajax": {                             "url": "data/json_users_list.php",                             "datasrc": "",                         },                          "columns": [                             { "data": "profile_photo_path" },                             { "data": "namebulk" },                             { "data": "email" },                             { "data": "active" },                             { "data": "id"}                         ],                         "columndefs": [                             { sclass: "hidden-xs hidden-sm", "targets": [ 0 ] },                             { sclass: "user-name", "targets": [ 1 ] },                             { sclass: "hidden-xs hidden-sm", "targets": [ 2 ] },                             { sclass: "action-links", "targets": [ 3 ] },                             { "width": "1%", "targets": 0 },                             {                             "targets": [ 4 ],                             "visible": false,                             "searchable": false                         }                         ],                         "fnrowcallback": function( nrow, adata, idisplayindex ) {                               $('td:eq(0)', nrow).html('<div style="background: url(\''+adata.profile_photo_path+'\');" class="image-circle-50" id="'+adata.id+'-img"></div>');                               $('td:eq(1)', nrow).html('<a onclick="$(\'#menu\').load(\'users_edit.php?id='+adata.id+'\');" class="name edit" id="showmenu"><span id="'+adata.id+'-first_name">'+adata.first_name+'</span> <span id="'+adata.id+'-last_name">'+adata.last_name+'</span></a><span id="'+adata.id+'-username">'+adata.username+'</span>');                                $('td:eq(3)', nrow).html('<a onclick="$(\'#menu\').load(\'users_edit.php?id='+adata.id+'\');" id="showmenu" class="edit"><i class="linecons-pencil"></i>edit</a><a class="delete" id="deactivate"><i class="linecons-trash"></i>deactivate</a>');                                return nrow;                         },                     } );                      var mytable = $('#user_list').datatable();                      yadcf.init(mytable, [                         {column_number : 0, filter_type: 'none'},                         {column_number : 1, filter_type: 'text'},                         {column_number : 2, filter_type: 'text'}                     ]);                   } );             </script> 

this specific line should initialase popconfirm

 <a class="delete" id="deactivate"><i class="linecons-trash"></i>deactivate</a> 

the popconfirm js found here: https://github.com/ifnot/popconfirm

here code initialise popconfirm on id of "deactivate":

    <script type="text/javascript">         $(document).ready(function() {              // custom title, content , placement             $("#deactivate").popconfirm({                 title: "are sure?",                 content: "all previous records of user maintained on system consistency",                 placement: "left",                 nobtn: "cancel"             });         });     </script>    

i have tried changing to:

$('#main-content').ready(function() {

and

$('body').ready(function() {

to make sure initialised appears in body or main-content div, still no luck....

am missing simple here, or popconfirm natively not going work this?

thanks

did add file in script tag: jquery.popconfirm.js in page? (see readme on https://github.com/ifnot/popconfirm)


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -