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