0

I am using this code for remove a row

$(document).on("click",
"#deleteSelection${cadenaAleatoria}",
function(){

$('.alertaGrillaResultado').css('display','inherit');
 var selectedModels = grid.getSelectedModels();

 if(selectedModels != ''){
_.each(selectedModels, function (model) {
  model.trigger("backgrid:select", model, false);
  var id = grid.collection.fullCollection.where({ id: model.id });
  grid.removeRow(id);
  $.get("@{delete()}/" + model.id, function (modelos) {
  });
  $('.alertaGrillaResultado').html(
        '<div class="alert alert-success">' + '<button type="button" class="close"      data-dismiss="alert">&times;</button>' + "Se retiro el Tipo de Eventualidad seleccionada" + '</div>'
    );
});
collection.fetch({reset:true});



  }

$('.alertaGrillaResultado').fadeOut(3000); });

but when I delete the last row of one page I get this error:

throw new RangeError("currentPage must be firstPage <= currentPage " + (firstPage ? ">" : ">=") + " totalPages if " + firstPage + "-based. Got " + currentPage + '.');

how to update pagination? how to resolve this?

marti_
  • 130
  • 5
  • 14
  • What exactly are u doing? Why are you deleting via jQuery instead of Backbone? Why are you fetching from 2 URLs into the same collection twice and is collection the same as grid.collection? – Y.H Wong Jan 26 '14 at 15:21
  • collection.fetch({url: 'tipoeventualidades/listavacia/',reset:true}); collection.fetch({url: 'tipoeventualidades/lista/',reset:true}); i correct this collection.fetch({url: 'tipoeventualidades/listavacia/',reset:true}); collection.fetch({reset:true}); – marti_ Jan 26 '14 at 16:38
  • My problem is when I page have only one item and I deleted it I get the error throw new RangeError. for example I have 4 pages and the last one (4) has 1 item – marti_ Jan 26 '14 at 16:40
  • What's your pageable's initial state? – Y.H Wong Jan 27 '14 at 10:15
  • also which versions of the libraries are u using? there used to be a bug related to this many months ago. – Y.H Wong Jan 27 '14 at 15:06
  • backgridjs i am using v0.2.* and few days ago I update the backbone-pageable – marti_ Jan 31 '14 at 16:03
  • I am using this collection.getLastPage(); and it works – marti_ Mar 03 '14 at 19:36

0 Answers0