Skip to main content

Bug Tracker

Side navigation

#12696 closed bug (invalid)

Opened October 10, 2012 07:09PM UTC

Closed October 25, 2012 09:04AM UTC

Catch element in one line HTML with jQuery

Reported by: konstantin.fedoseev@gmail.com Owned by: konstantin.fedoseev@gmail.com
Priority: undecided Milestone: None
Component: unfiled Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:
Description

We have CMS system, users can add HTML content with WYSIWYG editor. I need to find all images inside the editor that have image maps and remove blank space before those images.

We discovered the problem that jQuery can't catch some elements when whole HTML code of the editor represented as one line. But when we run the code via http://jsbeautifier.org/, jQuery able to catch those elements that was unable before. What the reason?

HTML code before Code Beautifier:

<tr><td> <img alt="" src="images/46.jpg" usemap="#rade_img_map_1349882725177" /></td></tr>

HTML code after Code Beautifier:

<tr>

<td>

 <img alt="" src="images/46.jpg" usemap="#rade_img_map_1349882725177" />

</td>

</tr>

jQuery function:

function FixBlankSpaces() {

var editorContents = $('#editEditor_contentIframe').contents();

$(editorContents).find('img[usemap]').each(function () {

var currentElement = $(this);

var thisContent = $(currentElement).parent().html();

///////Here the jQuery get's in trouble//////

if (thisContent.indexOf(' <img') > 0) {

$('#editEditor_contentIframe').contents().find($(currentElement)).parent().html($('#editEditor_contentIframe').contents().find($(currentElement)).parent().html().replace(/ /g, ''));

}

});

}

Attachments (0)
Change History (2)

Changed October 10, 2012 07:11PM UTC by dmethvin comment:1

owner: → konstantin.fedoseev@gmail.com
status: newpending
"jQuery can't catch some elements"

I don't understand what this means. Can you post a test case on jsfiddle.net?

Changed October 25, 2012 09:04AM UTC by trac-o-bot comment:2

resolution: → invalid
status: pendingclosed

Because we get so many tickets, we often need to return them to the initial reporter for more information. If that person does not reply within 14 days, the ticket will automatically be closed, and that has happened in this case. If you still are interested in pursuing this issue, feel free to add a comment with the requested information and we will be happy to reopen the ticket if it is still valid. Thanks!