31 lines
1 KiB
Text
31 lines
1 KiB
Text
// Handle more advanced DOM update after AJAX database manipulation.
|
|
// See publish/subscribe design pattern in /doc.
|
|
(function(w) {
|
|
|
|
$('#stock_articles_for_adding tr').removeClass('success');
|
|
|
|
if(<%= @supplier.id != @stock_article.supplier.id %>) {
|
|
// the stock_article does _NOT_ belong to the current supplier
|
|
var try_again = w.confirm('<%= j(
|
|
t('deliveries.form.confirm_foreign_supplier_reedit', :name => @stock_article.name)
|
|
) %>');
|
|
|
|
if(try_again) {
|
|
$.ajax({
|
|
url: '<%= j edit_stock_article_path(@stock_article) %>',
|
|
type: 'get',
|
|
contentType: 'application/json; charset=UTF-8'
|
|
});
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
// the stock_article _DOES_ belong to the current supplier
|
|
var stock_article_for_adding = $(
|
|
'<%= j(render(:partial => 'stock_article_for_adding', :locals => {:article => @stock_article})) %>'
|
|
).addClass('success');
|
|
|
|
$('#stock_articles_for_adding tbody').append(stock_article_for_adding);
|
|
updateSort('#stock_articles_for_adding');
|
|
})(window);
|