tags:

views:

41

answers:

1

I have the following code:

function CreateRoundbox(selector, scope) {
    $(selector).wrap('<div class=\"' + scope + ' dialog\"><div class=\"bd\"><div class=\"c\"><div class=\"s\"></div></div></div></div>');
    $('div.' + scope).prepend('<div class=\"hd\"><div class=\"c\"></div></div>').append('<div class=\"ft\"><div class=\"c\"></div></div>');
}

Whenever I use this function and the "wrap" method is called it causes the $(document).ready() method to fire for a second time on the page. Here is the call to the function (this lives in a document ready block):

CreateRoundbox(".roundbox", "roundbox-wrapper");      

Has anyone ran into this before? Am I using wrap wrong?

UPDATE

Fixed usage line, I accidentally added a dot in the scope literal

A: 
function CreateRoundbox(selector, scope) {
                            //           v----> this will result to class=".roundbox-wrapper", which is, I guess, not the thing you want in there.. :)
    $(selector).wrap('<div class=\"' + scope + ' dialog\"><div class=\"bd\"><div class=\"c\"><div class=\"s\"></div></div></div></div>');
    $('div.' + scope).prepend('<div class=\"hd\"><div class=\"c\"></div></div>').append('<div class=\"ft\"><div class=\"c\"></div></div>');
   //     ^    ^
   //     |    |--- look at scope.... then, look here at the second argument, CreateRoundbox(".roundbox", ".roundbox-wrapper");
   //     |--- look at the dot.... :)   CreateRoundbox(".roundbox", ".roundbox-wrapper");

}
Reigel
I see what you're saying...I'll update the example above...I just typed in the usage, and screwed it up ;)
Ryan Eastabrook
lol with the down-vote... I hope at least the reason was explained... for further enhancement of the answer.. ;)
Reigel
Yes, because it had no bearing on the actual answer (and I left a comment with an explanation, not to mention an update to the question). Had this been the answer to the question it would have gotten an upvote. Make sense?
Ryan Eastabrook
really?? before your update, it does... well, whatsoever, good luck...
Reigel
Thanks @reigel. As stated before, this was a typo. I appreciate you calling it out for me, but the typo wasn't intended. Remember the reason for upvote/downvote on questions....so that others can get the best answer to the question....in that vein, it has no bearing on answering the question (once the typo was removed). Nothing personal, SO rep is not everything my friend ;)
Ryan Eastabrook