mirror of
https://github.com/grocy/grocy.git
synced 2025-04-29 17:45:39 +00:00
36 lines
710 B
JavaScript
36 lines
710 B
JavaScript
$('#save-quantityunit-button').on('click', function(e)
|
|
{
|
|
e.preventDefault();
|
|
|
|
if (Grocy.EditMode === 'create')
|
|
{
|
|
Grocy.Api.Post('add-object/quantity_units', $('#quantityunit-form').serializeJSON(),
|
|
function(result)
|
|
{
|
|
window.location.href = U('/quantityunits');
|
|
},
|
|
function(xhr)
|
|
{
|
|
console.error(xhr);
|
|
}
|
|
);
|
|
}
|
|
else
|
|
{
|
|
Grocy.Api.Post('edit-object/quantity_units/' + Grocy.EditObjectId, $('#quantityunit-form').serializeJSON(),
|
|
function(result)
|
|
{
|
|
window.location.href = U('/quantityunits');
|
|
},
|
|
function(xhr)
|
|
{
|
|
console.error(xhr);
|
|
}
|
|
);
|
|
}
|
|
});
|
|
|
|
$('#name').focus();
|
|
$('#quantityunit-form').validator();
|
|
$('#quantityunit-form').validator('validate');
|