I am building my portfolio website simply using HTML
, Flash
, and the Mootools Javascript
framework. I have decided to implement a theme changing feature using Javascript and cookies. When the user clicks on the "Change Theme" link, a mediaboxAdvanced lightbox appears, containing a real-time form which allows you to change the theme on the portfolio.
Here's the code for the form:
<div id="mb_inline" style="display: none; margin:15px;">
<h3>Change Your Theme</h3>
<form>
<fieldset>
<select id="background_color" name="background_color">
<option value="#dcf589">Original</option>
<option value="#000FFF">Blue</option>
<option value="#00FF00">Green</option>
</select>
</fieldset>
</form>
</div>
I know, there is no submit button, but as soon as something is changed in that form, the following Mootools
code happens:
var themeChanger = new Class(
{
pageBody : null,
themeOptions : null,
initialize: function()
{
this.pageBody = $(document.body);
this.themeOptions = $('background_color');
this.themeOptions.addEvent('change', this.change_theme.bindWithEvent(this));
},
change_theme: function(event)
{
alert("Hello");
}
});
window.addEvent('domready', function() {
var themeChanger_class = new themeChanger();
});
Now this is only a test function, which should be triggered when the dropdown menu changes. However, it seems that none of it works when the form is in the lightbox! Now if I decide to run the form outside of the lightbox, then it works great!
It seems it can't even access the "background_color" element.
Am I missing something?
If you need more examples, I will fill in on demand.
Thank you all in advance.
-Christopher
Update (4/27/2010 - 12:54PM):
I looked into this a little more and have two theories about all of this.
1- In the mediaboxAdv.js
file, there's the following declaration:
$(document.body).adopt(
Could this keep me from accessing the body's properties, such as "background-color"?
2- Could the lightbox display that form as a page on its own, hence why I cannot access the parent page's body tag?
3- Do I need to declare my javascript file the following way?
<div id="mb_inline" style="display: none; margin:15px;">
<!-- script declaration -->
<script type="text/Javascript" src="scripts/themeChanger.js"></script>
<!-- the form -->
<h3>Change Your Theme</h3>
<form>
<fieldset>
<select id="background_color" name="background_color">
<option value="#dcf589">Original</option>
<option value="#000FFF">Blue</option>
<option value="#00FF00">Green</option>
</select>
</fieldset>
</form>
</div>
Update (4/27/2010 - 1:17PM):
Here's a screenshot of what I am trying to do, if it can help you guys.
Chances are I might post a link to the site so that you can see with your own eyes what I want to do.