|
@ -2,7 +2,7 @@ $('.btn').button(); |
|
|
|
|
|
|
|
|
$("#add_bike_submit").click(function(){ |
|
|
$("#add_bike_submit").click(function(){ |
|
|
|
|
|
|
|
|
json_data = { bike: { |
|
|
json_data = { bikes: [{ |
|
|
serial_number: $("#serial_number").val(), |
|
|
serial_number: $("#serial_number").val(), |
|
|
bike_brand_id: parseInt($("#bike_brand_id").val()), |
|
|
bike_brand_id: parseInt($("#bike_brand_id").val()), |
|
|
shop_id: parseInt($("#shop_id").val()), |
|
|
shop_id: parseInt($("#shop_id").val()), |
|
@ -12,15 +12,16 @@ $("#add_bike_submit").click(function(){ |
|
|
bike_condition_id: parseInt($('input[name=bike_condition]:checked').val()), |
|
|
bike_condition_id: parseInt($('input[name=bike_condition]:checked').val()), |
|
|
bike_purpose_id: 1, |
|
|
bike_purpose_id: 1, |
|
|
bike_wheel_size_id: parseInt($("#bike_wheel_size_id").val()), |
|
|
bike_wheel_size_id: parseInt($("#bike_wheel_size_id").val()), |
|
|
}}; |
|
|
}]}; |
|
|
|
|
|
|
|
|
$.ajax({ |
|
|
$.ajax({ |
|
|
url: $("#add_bike_submit").data("url"), |
|
|
url: $("#add_bike_submit").data("url"), |
|
|
type: "POST", |
|
|
type: "POST", |
|
|
data: json_data, |
|
|
data: JSON.stringify(json_data), |
|
|
|
|
|
contentType: 'application/json', |
|
|
dataType: "json", |
|
|
dataType: "json", |
|
|
success: function(data, status, xhr){ |
|
|
success: function(data, status, xhr){ |
|
|
window.location = "/bikes/"+ data.bike.id; |
|
|
window.location = data.bikes[0].href; |
|
|
}, |
|
|
}, |
|
|
error: function(data, status ){ |
|
|
error: function(data, status ){ |
|
|
displayFormErrors(data.responseJSON); |
|
|
displayFormErrors(data.responseJSON); |
|
|