working on hide add p article button js solution
This commit is contained in:
parent
8f89898817
commit
268b7f5bb4
@ -53,11 +53,11 @@ module DocumentLineHelper
|
||||
end
|
||||
|
||||
link_to name,"#",
|
||||
:onclick => "add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\");return false;",
|
||||
:onclick => "#{options[:js]} add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\");return false;",
|
||||
:class => (options[:class]),
|
||||
tabindex: options[:tabindex],
|
||||
style: options[:style]#,
|
||||
#data: options["data-qty_to_reach"]
|
||||
style: options[:style],
|
||||
data: options[:data]
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -6,9 +6,32 @@
|
||||
= f.semantic_fields_for :p_articles do |form|
|
||||
=render :partial => "admin/p_articles/form", :locals => {:form => form, @price_line => f.object}
|
||||
|
||||
%p= link_to_add_fields "Ajouter un article", f, :p_articles, {:class => "btn btn-primary"} if f.object.p_articles.count < f.object.qte
|
||||
%p= link_to_add_fields "Ajouter un article", f, :p_articles, {:class => "btn btn-primary", data: {qty_to_reach: @price_line.qte, qty: f.object.p_articles.count, btn_id: "add_p_article_id" }, js: "qty_check();"} if f.object.p_articles.count < f.object.qte
|
||||
%p= link_to_add_fields "Ajouter un article", f, :p_articles, {:class => "btn btn-primary disabled"} if f.object.p_articles.count >= f.object.qte
|
||||
|
||||
|
||||
=render :partial => "qi/actions", :locals => {:f => f}
|
||||
-# .actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||
|
||||
:javascript
|
||||
|
||||
|
||||
var qty = parseInt($('[data-btn-id="add_p_article_id"]').data("qty"))
|
||||
window.localStorage.setItem('qty', qty);
|
||||
console.log("ON PAGE LOAD " + window.localStorage.getItem('qty'))
|
||||
|
||||
|
||||
function qty_check() {
|
||||
//console.log($('[data-btn-id="add_p_article_id"]').length)
|
||||
var qtyToReach = parseInt($('[data-btn-id="add_p_article_id"]').data("qty-to-reach"))
|
||||
var qty = parseInt(window.localStorage.getItem('qty'))
|
||||
|
||||
console.log("qty " + qty)
|
||||
qty += 1
|
||||
console.log("qty " + qty)
|
||||
window.localStorage.setItem('qty', qty);
|
||||
|
||||
|
||||
$('[data-btn-id="add_p_article_id"]').attr('data-qty', qty);
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user