JSFiddle - React, Tailwind, and code Playground

by bluey

JavaScript

/****
*    The script i am trying to load with delegate()
*/

function stock_quantAdjustUp(){
	$(".stock_quant_adjust_up").mousehold(function() {	
		
		id = $(this).parent().parent().attr('id');
		var quant = $(this).parent().parent().attr('data-stock_level');
		var itemid = $('#'+id).attr('data-stock_id');
		//alert(id); //testing
		quant = parseInt(quant) + 1; 
		
		$('#'+id+'_num').text(quant);
		$('#'+id).attr('data-stock_level', quant);
		
		toUpdate = id+'_num';
		
		clearTimeout(stock_adjust_timer);
		stock_adjust_timer = setTimeout(function(){
			//Update db here
			//alert(quant);
			var url = "http://www.xxxxxxx.com/home/secure/bin/manage_stock/update_stocklevels.php";
			//var url = "test2.php";
			
			$.ajax({
						type: 'POST',
						url: url, 
						dataType: 'json',
						data: {
							itemid:itemid,
							quant:quant,
							toUpdate:toUpdate
						},
						beforeSend: function() {
								$('#'+id+'_num').html( "<img src='http://www.xxxxxx.com/home/secure/images/gif/ajax-loader.gif'></img>" );
						},
						success: function(data) {
								//alert(data);
								$('#'+data.toUpdate).html(data.quant);
								$('#'+data.toUpdate).addClass('updated_grn');
								//alert('quant:'+data.quant+'\nid:'+data.toUpdate);  //testing
						}
			});
			
		},200);
		
		//alert(quant);
	});
	
}




/****
*    The ajax that initializes the table
*/
                   $.ajax({
						type: 'POST',
						url: url, 
						dataType: 'html',
						 
						beforeSend: function() {
								document.getElementById("manage_stock_table_sec").innerHTML="<span class='blink_me'>Requesting..</span>";
						},
						success: function(html) {
								document.getElementById("manage_stock_table_sec").innerHTML=html;
							
								var url = "http://www.xxxxxxxx.com/home/secure/pos_js/manage_stock.js";
								$.getScript( url );
								
								
								$('#stock_management_table').dataTable();
								
								var stock_management_table =...