开发者

Problem with jQuery append in ie7

开发者 https://www.devze.com 2022-12-20 05:41 出处:网络
Hi guys I am having a very strange problem in ie with the append function. B开发者_运维问答asicly i retrieve data from an ajax call in xml. Parse the xml into variables then using the each function ap

Hi guys I am having a very strange problem in ie with the append function. B开发者_运维问答asicly i retrieve data from an ajax call in xml. Parse the xml into variables then using the each function append to a specific div. Works fine in firefox had to do a work around to get the file to parse in ie. Please note 'ALL WORKS' fine my variables etc. all have values etc.

However when I use the append function some of the text randomly appears outside its containing div see picture below:

alt text http://www.freeimagehosting.net/uploads/e21468dd49.png

As you can see some of the text overflows the container or almost seems to reflect ? Any way below is a snippet of the code where i make the append: I should also add I am opening this div in a dialog box created with jquery ui - which sets the containing div to display: block - so i am wondering if this is having any effect.

$(xml).find("entry").each(function()
{

var $item = $(this);
var title = $item.find("title").text();
var linkN = $item.find("link").attr("href");
var output = "<a href=\"" + linkN + "\" target=\"_self\">" + title + "<\/a>" + "<br />";
$("#notifyBox").append($(output));
$('#notifyBox').show();
});

Really hope you guys can help this is the strangest problem I have ever encountered.


Try this instead:

$(xml).find("entry").each(function()
{
  var $item = $(this);
  var title = $item.find("title").text();
  var linkN = $item.find("link").attr("href");
  var output = "<a href='" + linkN + "' target='_self'>" + title + "</a><br />";
  $("#notifyBox").append($(output)).show();
});

I believe your <\/a> is causing the issue, no need to escape the forward slash, browser is seeing it as an unclosed element.


I've solved this:

var a = '<span>Attachment: '+Filedata.substr(Filedata.lastIndexOf('\\')+1).toLowerCase()+'</span>';
var b = '<span ><a href="#" class="remove_link" style="cursor:pointer; ">Remove</a></span></br></br>';
                var c = a+' '+b; // use instead of append
                $('div.attach_file').hide();
                $('div.Multi_Attach_file').show().html(c); // display c


Well it seems a single float on the containing box (float: left) - was causing the issue - pesky ie - anyway hope this helps someone if they have the same problem. Thanks to Nick Craver hope helped me re-factor my code a bit - cheers

0

精彩评论

暂无评论...
验证码 换一张
取 消