From ee869c9ded967dfeb7be0fbaa04bf2f918e8d3e3 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Tue, 22 Aug 2017 16:08:48 +0630 Subject: [PATCH] update add order --- app/views/origami/addorders/show.html.erb | 37 ++++++++++++++--------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/app/views/origami/addorders/show.html.erb b/app/views/origami/addorders/show.html.erb index dd192fe7..2a01d664 100644 --- a/app/views/origami/addorders/show.html.erb +++ b/app/views/origami/addorders/show.html.erb @@ -181,7 +181,7 @@ $(function(){ code = instances[i].code; } }); - + row = '
' +'
' +''+ menu_items[field].name +'' @@ -212,29 +212,28 @@ $(function(){ //click item row for add order $(document).on('click', '.menu_item_box', function(event){ + $('.option-list').empty(); data = $(this).parent().children().children('.add_icon'); attributes = $(this).data('id'); selected_item = $(this).data('item'); - + console.log(attributes); for(var field in attributes) { value = attributes[field]["value"]; - + type = attributes[field]["type"] row = "

"+attributes[field]["type"]+"

" $(value).each(function(i){ - $(selected_item).each(function(item){ - if (value[i] == selected_item[item]) { - $('.custom-btn').addClass('selected-option'); - }else{ - $('.custom-btn').removeClass('selected-option'); - } - }); - console.log(jQuery.inArray(value[i], selected_item)); + status =""; + if(parseInt(jQuery.inArray(value[i], selected_item))!== -1){ + status = "selected-option"; + } - row +=''; - }); + row +=''; + + }); + $(".option-list").append(row); - $(".option-list").append(row); + } $('#change_qty').val(1); $('#title_name').text(data.attr('data-name')); @@ -242,6 +241,16 @@ $(function(){ $('#unit_price').text(data.attr('data-price')); }); + // click select option icon for add + $(document).on('click', '.custom-btn', function(event){ + type = $(this).data('type'); + $('+ type +').removeClass('selected-option'); + $(this).addClass('selected-option'); + + + }); //End selecct Click + + // click plus icon for add $(document).on('click', '.add_icon', function(event){ var item_data = $(this);