how to fix my JQuery bug?

sdcarg

New Member
The script is on jsfiddle here : CODEWhat it does at the moment: it's a form that have two types of URL field textarea and input, it converts the texts in those fields to a link to be click-able. How it works: if you click next to the link/links you can edit the link or on a double click on the link. IF you click once on the link it takes you to that page.Last update: i added the \[code\].trigger('blur');\[/code\] on the last line, Because before i did that, the text area was showing the links like one merged link, for example : \[code\]test.com\[/code\] and \[code\]test2.com\[/code\] were showing \[code\]test.comtest2.com\[/code\], after i added this last update, the split for textera work also on the load of page not just on the edit of textarea ( it was working without the last update but only when you edit the textarea and put between links a space, and i want it to be working on the load of page because the textarea format was sent already as one link pre row ).My problem: after i did this last update, the double click is messed up, it should just be able to edit the link and don't go to that page unless one click, but now it edits it and in like one second it goes also to that page. I want the double click just to edit without going to that page. and to go only with one click.Thanks a lot in advance!The code also here:\[code\]$('.a0 a').click(function(){\[/code\]\[code\]var href = http://stackoverflow.com/questions/11242349/$(this).attr('href');// Redirect only after 500 millisecondsif (!$(this).data('timer')) { $(this).data('timer', setTimeout(function () { window.open(href, '_blank') }, 500));}return false; // Prevent default action (redirecting)});$('.a0').dblclick(function(){clearTimeout($(this).find('a').data('timer'));$(this).find('a').data('timer', null);$(this).parent().find('input,textarea').val($(this).find('a').text()).show().focus();$(this).hide();})$('.a0').click(function(){ $(this).parent().find('input,textarea').val($.map($(this).find('a'),function(el){return $(el).text();}).join(" ")).show().focus();$(this).hide();})$('#url0, #url1,#url4').each(function(index, element){ $(element).blur(function(){ var vals = this.value.split(/\s+/), $container = $(this).hide().prev().show().empty();$.each(vals, function(i, val) { if (i > 0) $("<span><br /></span>").appendTo($container); $("<a />").html(val).attr('href',/^https?:\/\//.test(val) ? val : 'http://' + val).appendTo($container);;}); })}).trigger('blur');\[/code\]
 
Back
Top