Показать сообщение отдельно
  #7 (permalink)  
Старый 31.05.2018, 10:44
Интересующийся
Отправить личное сообщение для bipib Посмотреть профиль Найти все сообщения от bipib
 
Регистрация: 04.12.2017
Сообщений: 13

я понял что я сооружаю костыль но на ус друго не приходит.
Скажите такое будет работать если правильно экранировать кавычки
<script type="text/javascript"><!--
	var project_image_row = <?php echo $project_image_row; ?>;

	function addProjectImage() {
		html  = '<tr id="project_image-row' + project_image_row + '">';
		html += '  <td class="text-left"><a href="" id="thumb-image' + project_image_row + '" data-toggle="image" class="img-thumbnail"><img src="<?php echo $placeholder; ?>" alt="" title="" data-placeholder="<?php echo $placeholder; ?>" /></a><input type="hidden" name="project_image[' + project_image_row + '][image]" value="" id="input-project_image' + project_image_row + '" /></td>';
		html += '<td><div class="form-group" id="product-to-project' + project_image_row + '" style="display:inherit">';
		html += '	<label class="col-lg-2 col-md-2 col-sm-2 col-xs-12 control-label"><?php echo $entry_product; ?></label>';
		html += '		<div class="col-lg-10 col-md-10 col-sm-10 col-xs-12">';
		html += '			<input type="text" name="project_image[' + project_image_row + '][product_to_project]" value="" class="form-control" />';
		html += '			<div id="project-image-list' + project_image_row + '" class="well well-sm" style="height: 150px; overflow: auto; margin-bottom:0;">';
		html += '			</div>';
		html += '		</div>';
		html += '	</div></td>';
		html += '  <td class="text-right"><input type="text" name="project_image[' + project_image_row + '][sort_order]" value="" placeholder="<?php echo $entry_sort_order; ?>" class="form-control" /></td>';
		html += '  <td class="text-left"><button type="button" onclick="$(\'#project_image-row' + project_image_row  + '\').remove();" data-toggle="tooltip" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
		html += '</tr>';

		
		html += '	<script type="text/javascript">';
		html += '		$(\'input[name=\'project_image[' + project_image_row + '][product_to_project]\']\').autocomplete({';
		html += '			\'source\': function(request, response) {';
		html += '				$.ajax({ url: \'index.php?route=catalog/product/autocomplete&token=<?php echo $token; ?>&filter_name=' +  encodeURIComponent(request), dataType: 'json', success: function(json) { response($.map(json, function(item) { return { label: item['name'], value: item['product_id'] }	})); }	});	},';
		html += '			'select': function(item) {';
		html += '				$('input[name=\'project_image[' + project_image_row + '][product_to_project]\']').val('');';
		html += '				$('#product-to-project-list' + project_image_row + '_' + item['value']).remove();';
		html += '				$('#project-image-list' + project_image_row + '').append('<div id='product-to-project-list' + project_image_row + '_' + item['value'] + ''><i class='fa fa-minus-circle'></i> ' + item['label'] + '<input type='hidden' name='project_image[' + project_image_row + '][product_to_project][]' value='' + item['value'] + '' /></div>');';
		html += '			}';
		html += '		});';
		html += '		$('#project-image-list' + project_image_row + '').delegate('.fa-minus-circle', 'click', function() {';
		html += '			$(this).parent().remove();';
		html += '		});';
		html += ' </script>';

		$('#project_images tbody').append(html);

		project_image_row++;
	}
Ответить с цитированием