S
S
Sergey Bard2018-03-29 11:38:11
JavaScript
Sergey Bard, 2018-03-29 11:38:11

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>

js
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();
  });
});

everything works correctly except for one, I can't copy any group of cells and paste into this table, i.e. inside this generated table there is no possibility to paste the copied data and copy in the same way, you can just edit individual cells, but there is no copy / paste. At first I wrote that if you load the entire table with data immediately with the page, then everything is OK, but if through ajax and modal it doesn’t work.
There is no possibility, this means that I press ctrl + then ctrl + v, but it does nothing, I just copy and try to paste into the editor or somewhere else, and I paste the data from the buffer that I copied before
Please tell me what I'm doing it wrong.
Ps I tried it on several computers, and in different browsers, and everything worked as it should only in opera on one PC and in edge, I don’t understand what the problem is at all, the debugger does not write any errors

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Bard, 2018-04-03
@serg_small_developer

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');
  });
});

those. at the end i did like this after i removed this line everything worked properly

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question