Answer the question
In order to leave comments, you need to log in
Why doesn't copy and paste work in a modal window?
Hello. I just can’t understand what’s the matter, I use this lib , if this table is formed when the page is loaded, then everything is fine, but I need to make sure that after loading the page, the user can click the appropriate button and show him a table with the necessary data in the modal, I do this so
modal
<div id="modalItem" tabindex="-1" role="dialog" data-keyboard="false" aria-labelledby="modal-title" aria-hidden="true">
<div class="row-col h-v">
<div class="row-cell v-m">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
</div>
<div class="modal-body text-center">
<div id="hot" class="hot handsontable"></div>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</div>
</div>
var container = document.getElementById('hot');
var hot;
hot = new Handsontable(container, {
fillHandle: false,
rowHeaders: true,
fixedColumnsLeft: 1,
colHeaders:
['header1', 'header2', 'header3'],
columns: [
{data: 'var1', readOnly: true},
{data: 'var2',},
{data: 'var3',},
],
afterChange: function (change, source) {
if (source === 'loadData') {
return; //don't save this change
}
}
});
var load = document.getElementById("button");
Handsontable.dom.addEvent(load[0], 'click', function() {
$.ajax({
type: 'POST',
url: 'url',
})
.done(function(result) {
var data = [];
$.each(result.answer, function( index, value ) {
data.push( {
var1: value.var1,
var2: value.var2,
var3: value.var3,
} );
});
hot.loadData(data);
hot.render();
});
});
Answer the question
In order to leave comments, you need to log in
maybe it will be useful for someone, the full code was like this
Handsontable.dom.addEvent(load[0], 'click', function() {
$.ajax({
type: 'POST',
url: 'url',
})
.done(function(result) {
var data = [];
$.each(result.answer, function( index, value ) {
data.push( {
var1: value.var1,
var2: value.var2,
var3: value.var3,
} );
});
hot.loadData(data);
hot.render();
$('#modalItemDel').modal('show');
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question