|
-
September 23rd, 2007, 11:10 AM
#16
Re: innerHTML in head
Isn't this a more clean and general way to do it?
Code:
function addScript(window_number) {
var prefix = "window_" + window_number + "_";
var wone = $(prefix + "wone");
var container = wone.getParent();
var fx = new Fx.Style(wone, "opacity").start(0, 1);
wone.makeResizable({ handle: $(prefix + "botright"), container: container });
$(prefix + "inner").makeResizable({ handle: $(prefix + "botright"), container: container });
wone.makeDraggable({ handle: $(prefix + "handle"), container: container });
wone.style.height = "257px";
}
Then use it like so:
Code:
// Add script to windows #1 and #2.
addScript(1); addScript(2);
-
September 23rd, 2007, 03:00 PM
#17
Re: innerHTML in head
 Originally Posted by Kovo88
using eval() maybe?
Don't ever use eval() unless you are 100% in control of what it is about to do. It is very powerful, but sometimes too powerful. It can and will execute anything passed to it!
If the post was helpful...Rate it! Remember to use [code] or [php] tags.
-
September 23rd, 2007, 06:26 PM
#18
Re: innerHTML in head
blixt, your script makes sense, but still does not help my code need.
I will give you the simplest example. I am making a button that will create a large chunk of html everytime it is clicked. The chunk of html is made up of DIVs, text etc. Some of these divds have ID's and some have classes. The script I am trying to reproduce defines many effects (via mootools). These effects are ID SPECIFIC. So when Someone clicks the button 3 times, I need all 3 chuncks of code to be usable i.e. the script must be reproduced 3 times with the wundow_number being different for all three and the elemnets picking up the effects from the script. All without refreshing the page!
Its tricky.
-
September 24th, 2007, 01:37 AM
#19
Re: innerHTML in head
You want to create a new set of elements every time a button is clicked. Each set of elements should share a number in their ID's. Is this correct?
The function I posted will work, and here's how you'd use it with the generation code:
Code:
<button onclick="newWindow()">New window</button>
Code:
var window_number = 1;
function newWindow() {
var prefix = "window_" + window_number + "_";
var wone = document.createElement("div");
wone.id = prefix + "wone";
var botright = document.createElement("div");
botright.id = prefix + "botright";
var inner = document.createElement("div");
inner.id = prefix + "inner";
// someElement.appendChild(wone);
// ...
addScript(window_number);
window_number++;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|