Welcome Guest [Log In] [Register]
This board has been archived and is no longer accepting new questions. If you have a support question for your ZetaBoard, please visit us at the new support board. Registration is free and easy.


Visit the NEW ZetaBoards Support forum!

Username:   Password:
Add Reply
issue with .contents() and .wrap()
Topic Started: Jun 25 2008, 12:06 AM (531 Views)
BRYN
The Guy with the Things for the Stuff
[ *  *  * ]
I'm skinned a forum I'm making off of an IF skin I liked, and the quote/code box as a detailed look to it.
I'm trying to incorporate this look into the spoiler box, but I'm having trouble.

First, the code strand is this:
Code:
 
$("div.spoiler:hidden").contents().wrap("<div class='spoiler_box'></div>");
I'm trying to wrap the hidden contents in a div in order to style it to my skin.

The problem I'm having, is that wither the wrap code, or the contents code (or both combined for that matter), are making it so that every line of text in the spoiler (even the blank lines (<br />)) are being wrapped in a div individually, and not as a whole.

I just want to know if my code has something conflicting, of if there is something I can add to stop everything being individually wrapped.
Offline Profile Quote Post Goto Top
 
Chris
Member Avatar
Member
[ *  *  *  * ]
try prepend and append instead.

Code:
 
$("div.spoiler:hidden").prepend("<div class='spoiler_box'>").append("</div>");
Edited by Chris, Jun 25 2008, 01:51 PM.
Offline Profile Quote Post Goto Top
 
BRYN
The Guy with the Things for the Stuff
[ *  *  * ]
First, I don't think you can prepend/append partial strands like that.
I tried doing it before and it just posted strands that self close and have no contents.

Secondly, that code does nothing.
I see no new divs.
Offline Profile Quote Post Goto Top
 
rockon1824
Member Avatar
Member
[ *  * ]
^That's because he spelled "div" as "dive" at the beginning of the code. xD

I hate it when I make stupid little mistakes like that too.
Offline Profile Quote Post Goto Top
 
Chris
Member Avatar
Member
[ *  *  *  * ]
opps XD

They self close? that's kinda crummy..
Offline Profile Quote Post Goto Top
 
BRYN
The Guy with the Things for the Stuff
[ *  *  * ]
I fixed the spelling mistake, but the code changed to what I thought it would: a strand that self closes.

This what what the code did:
Code:
 
<div class="spoiler">
<div class="spoiler_box"/>
text in the spoiler.
<br />
<br />
more text.
</div>


Any other suggestions?
Offline Profile Quote Post Goto Top
 
Chris
Member Avatar
Member
[ *  *  *  * ]
Actually yes; just though of one.

Give me a minute.

Code:
 
$("div.spoiler:hidden").each(function(){
new = $("<div class='spoiler_box'></div>").html($(this).html());

$(this).html(new);
});
Edited by Chris, Jun 25 2008, 01:57 PM.
Offline Profile Quote Post Goto Top
 
BRYN
The Guy with the Things for the Stuff
[ *  *  * ]
That code gives Firebug a syntax error.

It highlights the line in the code that has nothing in it.
Offline Profile Quote Post Goto Top
 
Chris
Member Avatar
Member
[ *  *  *  * ]
hmm

Code:
 
$("div.spoiler:hidden").each(function(){
$(this).html($("<div class='spoiler_box'></div>").html($(this).html()));
});


I tested it this time ^_^
Edited by Chris, Jun 25 2008, 03:57 PM.
Offline Profile Quote Post Goto Top
 
BRYN
The Guy with the Things for the Stuff
[ *  *  * ]
Perfect! Thank You!

There is another issue I was having with my old code that still with this code, but If you don't have a solution, I can live without one.


When previewing the post (div#c_post-preview), the div.spoiler_box doesn't show.
Now, I believe this is because div#c_post-preview doesn't even generate till you click the preview post button. Thus, not even :hidden will work.

If you have any ideas fore a solution?

If you don't have one, thats fine, because this only affects post previews.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · jQuery Help · Next Topic »
Add Reply