Answer the question
In order to leave comments, you need to log in
Which function in ruby/javascript collapses a table?
Good day.
There is a site written in Ruby, in which there are a lot of crutches (4 freelancers worked on the site). The problem is that when the amount of goods in the basket increases, the table automatically collapses and the delivery is reset to zero.
Question: where does the incorrect processing occur, on the server or user side?
javascript
var postQuantity = Restangular.all('api/quantity.json');
$scope.plusQuantity = function(id, type) {
$scope.quantityPromise = postQuantity.post({id: id, type: type, method: 'plus'}).then(
function(success) {
// refresher_cart_stat();
$scope.getCart();
},
function(data) { if (debug) { console.log("ERROR_ID75343354", data); if (is_safari) { alert('ERROR_ID93487534'); location.reload(); } } }
);
};
$scope.minusQuantity = function(id, type) {
$scope.quantityPromise = postQuantity.post({id: id, type: type, method: 'minus'}).then(
function(success) {
// refresher_cart_stat();
$scope.getCart();
},
function(data) { if (debug) { console.log("ERROR_ID85844445", data); if (is_safari) { alert('ERROR_ID84930584'); location.reload(); } } }
);
};
get :add, :map => '/add-to-cart/:id' do
type = params[:type].present? ? params[:type] : "standard"
curr_item = { "id" => params[:id], "quantity" => params[:quantity], "type" => type }
if session[:cart].nil?
cart = Array.new()
else
cart = session[:cart]
end
incart = false
cart.each_with_index do |item, index|
if item["id"] == curr_item["id"] && (item["type"] == curr_item["type"] || (item["type"].blank? && curr_item["type"] == "standart" ))
cart[index]["quantity"] = (cart[index]["quantity"].to_i + curr_item["quantity"].to_i).to_s
incart = true
end
end
if incart
session[:cart] = cart
else
session[:cart] = cart.push(curr_item)
end
#redirect(back, :notice => 'Товар добавлен в корзину.')
erb 'SUCCESS!'
end
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question