Javascript-форум (https://javascript.ru/forum/)
-   Общие вопросы Javascript (https://javascript.ru/forum/misc/)
-   -   отключить setTimeout (https://javascript.ru/forum/misc/60138-otklyuchit-settimeout.html)

ROMAN26 12.12.2015 23:51

отключить setTimeout
 
Здравствуйте. Заранее извиняюсь за то, что могу не правильно описать свою проблему, так как не имею глубоких знания в программировании. Есть сайт со списком товаров и кнопка "удалить" которая удаляет весь список товаров. В этом и заключается моя проблема, что после нажатия происходит удаление всех товаров, а мне требуется удаление одного товара после каждого нажатия данной кнопки. Подозреваю что проблема заключена в setTimeout.
Подскажите пожалуйста что нужно исправить в скрипте:


function Get(href,fx)
{
	$.get(href,fx).fail(function(){
		Get(href,fx)
	});
}

Pull = {
	i: 0,
	obs: null,
	init: function()
	{
		this.obs = document.querySelectorAll('.icon-text--delete');
		return this;
	},
	item: function()
	{
		var r = this.obs[this.i];
		//$('span').css('opacity',1);
		//document.getElementById('span'+this.i).style.opacity = 0.5;
		++this.i;
		this.i = (this.i >= this.obs.length) ? 0 : this.i;
		return r;
	},
	next: function()
	{
		setTimeout(function()
		{
			Pull._next();
		},1000);
	},
	_next: function()
	{
		var item = this.item();
		console.log(item);
		//item.onclick();
		$(item).click();
		this.next();
	}
};
$(document).ready(function()
{
	var d = document.createElement('script');
	d.innerHTML = function()
	{
		function confirm()
		{
			return true;
		};
		function alert(str)
		{
			console.log(str);
		};
	}.toString().replace(/function ?\([^\)]*\)[\r\n\t ]*\{/,'').replace(/\}$/,'');
	document.querySelector('head').appendChild(d);
	d = null;
	var $b = $($('table tbody tr th').get(0));
		$b.html($b.html()+' <button id="mt_del"><div >Удалить</div></button>');
	$('#mt_del').on('click',function()
	{
		this.setAttribute('disabled','disabled');
		Pull.init().next();
	});
});

ROMAN26 13.12.2015 17:18

помогите пожалуйста:cray:

Mess4me 13.12.2015 19:04

ROMAN26,
html бы еще плиз


Часовой пояс GMT +3, время: 22:55.