Loading js/block-class.js +33 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ removeAttributeItem(); verify_to_disable_add_more_attribute_button(); /** * This method will verify if there is validated items and should be displayed. */ Loading Loading @@ -61,6 +63,8 @@ */ function addAnotherAttributeItem() { console.log('Entrou no addAnotherAttributeItem'); $(".block-class-add-another-attribute").unbind().click(function(event) { // Prevent Default to stop the normal behavior and avoid going to Loading @@ -73,6 +77,8 @@ $('.hidden-attribute-field').first().removeClass('hidden-attribute-field'); verify_to_disable_add_more_attribute_button(); }); } Loading Loading @@ -102,6 +108,8 @@ }); verify_to_disable_add_more_attribute_button(); } // On click to add another item, prevent default to stop going to another Loading Loading @@ -198,6 +206,31 @@ } /** * This method will verify if there is another attribute to be added. */ function verify_to_disable_add_more_attribute_button() { var qty_attributes_per_block = $('.multiple-textfield-attribute').length; var qty_attributes_in_the_page = $('.displayed-attribute-field').length; // Verify if the qty items in the settings page is the same in the page. if (qty_attributes_per_block == qty_attributes_in_the_page) { // If yes disable the button to add more. $('.block-class-add-another-attribute').prop('disabled', true); return; } // If there is more, add the button to add more to be possible to add // new items in the page. $('.block-class-add-another-attribute').prop('disabled', false); } /** * This method will verify if is the last one that can't be removed. */ Loading Loading
js/block-class.js +33 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ removeAttributeItem(); verify_to_disable_add_more_attribute_button(); /** * This method will verify if there is validated items and should be displayed. */ Loading Loading @@ -61,6 +63,8 @@ */ function addAnotherAttributeItem() { console.log('Entrou no addAnotherAttributeItem'); $(".block-class-add-another-attribute").unbind().click(function(event) { // Prevent Default to stop the normal behavior and avoid going to Loading @@ -73,6 +77,8 @@ $('.hidden-attribute-field').first().removeClass('hidden-attribute-field'); verify_to_disable_add_more_attribute_button(); }); } Loading Loading @@ -102,6 +108,8 @@ }); verify_to_disable_add_more_attribute_button(); } // On click to add another item, prevent default to stop going to another Loading Loading @@ -198,6 +206,31 @@ } /** * This method will verify if there is another attribute to be added. */ function verify_to_disable_add_more_attribute_button() { var qty_attributes_per_block = $('.multiple-textfield-attribute').length; var qty_attributes_in_the_page = $('.displayed-attribute-field').length; // Verify if the qty items in the settings page is the same in the page. if (qty_attributes_per_block == qty_attributes_in_the_page) { // If yes disable the button to add more. $('.block-class-add-another-attribute').prop('disabled', true); return; } // If there is more, add the button to add more to be possible to add // new items in the page. $('.block-class-add-another-attribute').prop('disabled', false); } /** * This method will verify if is the last one that can't be removed. */ Loading