Uses the table from the bootstrap-table library and its extension table editable (original: x-editable ). The problem is that the editable-init.bs.table and editable-save.bs.table events proposed for use either do not work, or I am doing something wrong. The ultimate goal is to keep the value in base. Has anyone ever been there? If so, how do you work with the above events?

Creating a table:

 function createBootstrapTable(tab_wrapper_id, targetUrl) { $('#'+tab_wrapper_id).bootstrapTable({ method: 'get', url: targetUrl, cache: false, pagination: false, showRefresh: true, showFooter: true, editable: true, sidePagination: 'server', pageSize: 100, pageList: [10, 25, 50, 100] }); } 

Event:

 $('#' + tab_wrapper_id).on('editable-save.bs.table', function() { $('.editable').on('save',function(e, params){ console.log(123); }); }); 
  • one
    I advise you to add code to the question text to reproduce the problem - Athari
  • Thanks for the advice! - kirilldrozdovs
  • Is it possible to arrange all the code in the sandbox? - YozhEzhi
  • Perhaps your item has been added to the DOM after it has been loaded $(document).find('#' + tab_wrapper_id).on('editable-save.bs.table', function() { $('.editable').on('save',function(e, params){ console.log(123); }); }); - Vanya Avchyan
  • Yes, and check the uniqueness of your id element. In general, try to turn this fse using classes. - Vanya Avchyan

1 answer 1

Without a complete example is difficult to say. Most likely as you and said:

  • you are not catching there (the wrong element for the interception of events, dynamic binding or typo)
  • you catch the wrong thing (typo in the name of the event)

Here is a fully working example:

HTML

 <div class="alert alert-success" id="eventsResult"> Here is the result of event. </div> <table id="eventsTable"> </table> <hr> 

Js

 var data = [{ "id": 0, "name": "Item 0", "price": "$0" }, { "id": 1, "name": "Item 1", "price": "$1" }, { "id": 2, "name": "Item 2", "price": "$2" }, { "id": 3, "name": "Item 3", "price": "$3" }]; $(document).ready(function() { var $result = $('#eventsResult'); $('#eventsTable').on('all.bs.table', function(e, name, args) { console.log('Событие:', name, ', data:', args); }) .on('click-row.bs.table', function(e, row, $element) { $result.text('Событие: click-row.bs.table'); }) .on('dbl-click-row.bs.table', function(e, row, $element) { $result.text('Событие: dbl-click-row.bs.table'); }) .on('sort.bs.table', function(e, name, order) { $result.text('Событие: sort.bs.table'); }) .on('check.bs.table', function(e, row) { $result.text('Событие: check.bs.table'); }) .on('uncheck.bs.table', function(e, row) { $result.text('Событие: uncheck.bs.table'); }) .on('check-all.bs.table', function(e) { $result.text('Событие: check-all.bs.table'); }) .on('uncheck-all.bs.table', function(e) { $result.text('Событие: uncheck-all.bs.table'); }) .on('load-success.bs.table', function(e, data) { $result.text('Событие: load-success.bs.table'); }) .on('load-error.bs.table', function(e, status) { $result.text('Событие: load-error.bs.table'); }) .on('column-switch.bs.table', function(e, field, checked) { $result.text('Событие: column-switch.bs.table'); }) .on('page-change.bs.table', function(e, number, size) { $result.text('Событие: page-change.bs.table'); }) .on('search.bs.table', function(e, text) { $result.text('Событие: search.bs.table'); }) .on('editable-save.bs.table', function(editable, field, row, oldValue, $el) { $result.text('Событие: editable-save.bs.table'); }) .on('editable-shown.bs.table', function(editable, field, row, $el) { $result.text('Событие: editable-shown.bs.table'); }) .on('editable-hidden.bs.table', function(editable, field, row, oldValue, $el) { $result.text('Событие: editable-hidden.bs.table'); }) .on('editable-init.bs.table', function() { $result.text('Событие: editable-init.bs.table'); }); $('#eventsTable').bootstrapTable({ columns: [{ field: 'id', title: 'id' }, { field: 'name', title: 'name', editable: { type: 'text' } }, { field: 'price', title: 'price', editable: { type: 'text' } }], data: data }); }); 

Link to the sandbox: http://jsfiddle.net/pvkovalev/71m1yqz9/

Hope this helps you. Good luck. 🙂

  • May 2015. Is it late? :) - user207618
  • @Aid not, ok 🙂 can still help someone. I included many events in the answer, until I was tired of typing, so there is a chance 🙂 - pvkovalev
  • one
    @pvkovalev Thank you very much for such a detailed response! :-) It seems like the editable-save.bs.table event is being caught. - kirilldrozdovs