Hey all! I have some code that is behaving strangely, and I can't
seem to find any info on it.
Basically, I'm trying to go from this:
<div id="some_div">
<h1>Some Header</h1>
</div>
to this:
<div id="some_div">
<div class="listwrap">
<input type="button" class="previous" value="↑">
<h1>Some Header</h1>
<input type="button" class="previous" value="↑">
</div>
</div>
I've done wraps like this before, but never had this problem. Here's
what I'm getting...
<div id="some_div">
<div class="listwrap">
<input type="button" class="previous" value="&uarr;">
[object HTMLHeadingElement]
<input type="button" class="next" value="&darr;">
</div>
</div>
As you can see, the entities in my buttons' value attributes are being
messed with (though I've added an unescapeHTML call to try to fix
that) and, though this seems like a separate problem, when I insert
the H1 element into the new DIV, it is inserted as a string
representation of the actual element.
I'm just so confused by this. I'd love a nudge in the right direction
if anybody can spare a moment.
Here's the code in the function. "this.el" refers to the enclosing
"some_div".
wrap: function() {
var prev_value = this.orientation == 'horizontal' ? '←' :
'↑';
var next_value = this.orientation == 'horizontal' ? '→' :
'↓';
prev_value = prev_value.unescapeHTML();
next_value = next_value.unescapeHTML();
//make a new div for the top
var w = new Element('div',{'class':'listwrap'});
var h = this.el.select('h1');
var p = new Element('input',{
'type':'button',
'class':'previous',
'value': prev_value
});
var n = new Element('input',{
'type':'button',
'class':'next',
'value': next_value
});
this.el.insert({top: w});
w.insert({bottom: p});
w.insert({bottom: h});
w.insert({bottom: n});
},
Thanks so much (in advance)
Ian R
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---