optimized add form for store products
This commit is contained in:
@@ -320,14 +320,9 @@
|
||||
$(document).on('button click', '.removeRow', function(){
|
||||
var str = $(this).closest('tr').attr('class');
|
||||
var trCount = $('#tableRow tbody').children('tr').length;
|
||||
|
||||
if(trCount == 2){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(trCount == 3){
|
||||
$('#addnew-btn-tbl-row').remove();
|
||||
$('.tr-remove-btn').html('<button type="button" id="addNewRow" class="btn btn-success btn-sm btn-roster-action" data-toggle="tooltip" title="Add Another"><i class="fa fa-plus" aria-hidden="true"></i></button>');
|
||||
if(trCount <= 2){
|
||||
$('#addnew-btn-tbl-row').html('');
|
||||
$('.tr-remove-btn').html('<button type="button" id="addNewRow" class="btn btn-success btn-sm btn-roster-action" data-toggle="tooltip" title="Add Another"><i class="fa fa-plus" aria-hidden="true"></i></button>');
|
||||
}
|
||||
$('.'+str).remove();
|
||||
});
|
||||
@@ -395,24 +390,23 @@
|
||||
|
||||
|
||||
// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ adding of rows @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
||||
$(document).on('button click', '#addNewRow', function(){
|
||||
var TemplateCode = $('#template_code').val();
|
||||
var avalable_sizes = $('#avalable_sizes').val();
|
||||
// var TemplateCode = $('#template_code').val();
|
||||
// var avalable_sizes = $('#avalable_sizes').val();
|
||||
var p_id = $('#p_id').val();
|
||||
|
||||
// console.log(TemplateCode)
|
||||
var orderCounterValue = $('#orderCounterValue').val();
|
||||
var numi = document.getElementById('orderCounterValue');
|
||||
var num = (document.getElementById('orderCounterValue').value -1) + 2;
|
||||
numi.value = num;
|
||||
// var orderCounterValue = $('#orderCounterValue').val();
|
||||
// var numi = document.getElementById('orderCounterValue');
|
||||
// var num = (document.getElementById('orderCounterValue').value -1) + 2;
|
||||
// numi.value = num;
|
||||
|
||||
$.ajax({ //create an ajax request to load_page.php
|
||||
type: "POST",
|
||||
url: "{{ url('/designer/a/add-new-row') }}",
|
||||
data:{
|
||||
|
||||
itemCount : num,
|
||||
tempCode : TemplateCode,
|
||||
avalable_sizes : avalable_sizes
|
||||
url: "{{ url('/teamstore/q/add-new-row') }}",
|
||||
data: {
|
||||
p_id : p_id
|
||||
},
|
||||
|
||||
dataType: "html", //expect html to be returned
|
||||
@@ -424,11 +418,22 @@
|
||||
}
|
||||
xhr.setRequestHeader( 'X-Requested-With', 'XMLHttpRequest');
|
||||
},
|
||||
|
||||
success: function(response){
|
||||
var className = "row" + (num - 1);
|
||||
|
||||
var d = new Date();
|
||||
var n = d.getTime();
|
||||
|
||||
var parser = new DOMParser();
|
||||
var doc = parser.parseFromString(response, "text/html");
|
||||
var elem = doc.getElementById("orderTableBody");
|
||||
var currentClassName = elem.getElementsByTagName('tr')[0].className;
|
||||
elem.getElementsByClassName(currentClassName)[0].classList.remove(currentClassName); // remove current Classname
|
||||
elem.getElementsByTagName('tr')[0].classList.add("table-tr-" + Math.ceil(Math.random() * 999999) + n); // add random classname
|
||||
$('#tableRow tbody').append(elem.innerHTML);
|
||||
$('#addnew-btn-tbl-row').html('')
|
||||
$('#addnew-btn-tbl-row').append('<button type="button" id="addNewRow" class="btn btn-success btn-sm pull-left" data-toggle="tooltip" title="Add Another"><i class="fa fa-plus" aria-hidden="true"></i> Add Row</button>');
|
||||
$('.tr-remove-btn').html('<button type="button" class="btn btn-danger btn-sm removeRow btn-roster-action" data-toggle="tooltip" title="Remove"><i class="fa fa-remove" aria-hidden="true"></i></button>');
|
||||
$('#addnew-btn-tbl-row').remove();
|
||||
$('#tableRow tbody').append(response);
|
||||
$('#orderListPanel').scrollTop($('#orderListPanel')[0].scrollHeight);
|
||||
$('.inputName').keyup(function() {
|
||||
this.value = this.value.toLocaleUpperCase();
|
||||
|
||||
Reference in New Issue
Block a user