| SitePoint Sponsor |


Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
I have made few additional changes as well. It has fixed part of the problem.
Total changes made:
Removed this code:Code:function Custom_rounded_container(selector, color) { /* if(selector == undefined) { alert("selector is undefined"); } else { alert("selector is: " + " " + selector); alert("Inside Custom_rounded_container"); } */ alert("Inside Custom_rounded_container"); this.temp_array = selector && selector.split(" "); //alert(this.temp_array); this.color = color; }
Made change in All_rounded_corners_one_element function:Code:All_rounded_corners_one_element.prototype.superclass = Custom_rounded_container;
NowCode:function All_rounded_corners_one_element(selector, color) { alert("Inside All_rounded_corners"); Custom_rounded_container.call(this); //this.superclass(selector, color); }
Code:function Factory_rounded_corners(selector, color, type, numb_elem) { var rounded_container; if(numb_elem == "one" && type == "all_round") { rounded_container = new All_rounded_corners_one_element(selector, color); alert(rounded_container.color);//Still Not working alert(rounded_container.temp_array); // Still Not working rounded_container.elements_to_be_affected();//Working } }
It has fixed what originally was not working but now what was originally working is now not working..lol


Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
Opps sorry I'l update jsfiddle.
First time I'm using it so forgot to update it.


Currently you have mootools loaded, with the javascript activating in the web pages onload event.
You should use no library instead of mootools, change the loading to no wrap (in body).
After that the HTML code should have the scripting code at its end removed, and placed at the end of the scripting section instead.
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
I don't think I'm using it correctly. I have done as you said.
After reading the jsfiddle documentation under Fiddle Settings (Sidebar) section:
it says 'no wrap(body):
do not wrap the JavaScript code, place it in <body> section'
I have now added body tags in html section and moved the javascript code from below the html section to just below the body section.
Is that what you meant?
The updated javascript if it makes it easier:
Code:/* Function Factory_rounded_corners * ------------------------- * Parameter: selector * Return: None * Description: Create a rounded container around elements to be affected */ function Factory_rounded_corners(selector, color, type, numb_elem) { var rounded_container; if(numb_elem == "one" && type == "all_round") { rounded_container = new All_rounded_corners_one_element(selector, color); alert(rounded_container.color);//works alert(rounded_container.temp_array); // works rounded_container.elements_to_be_affected();//Does not work } } /* Function All_rounded_corners * ------------------------- * Parameter: selector * Return: None * Description: Create a rounded container around elements to be affected */ function All_rounded_corners_one_element(selector, color) { alert("Inside All_rounded_corners"); Custom_rounded_container.call(this); //this.superclass(selector, color); } /* Function custom_rounded_container * ---------------------------------- * Parameters: selector * Properties: this.temp_array * Methods: this.elements_to_be_affected, this.apply * Returns: Returns a object * Description: selector parameter should be in two formats: id of element if only one element is to be affected ie: 'content' or id of surrounding element and the tag of the elements to be affected, ie: 'content li' */ function Custom_rounded_container(selector, color) { /* if(selector == undefined) { alert("selector is undefined"); } else { alert("selector is: " + " " + selector); alert("Inside Custom_rounded_container"); } */ alert("Inside Custom_rounded_container"); this.temp_array = selector && selector.split(" "); //alert(this.temp_array); this.color = color; } Custom_rounded_container.prototype.test = function() { alert("Inside test"); } /* Function elements_to_be_affected * ---------------------------------- * Parameters: None * Properties: None * Local variables: None * Local methods: None * Returns: elements in array or one element * Description: Custom_rounded_container that retrieves elements to be affected */ Custom_rounded_container.prototype.elements_to_be_affected = function() { alert("Inside elements_to_be_affected"); //alert(this.temp_array.length); //return = document.getElementById(this.temp_array[0]).getElementsByTagName(this.temp_array[1]); /* children_elements = function(parent_element) { switch(parent_element.nodeName) { case 'UL': return parent_element.getElementsByTagName("li"); } } */ //return children_elements(parent_element[0]); } //All_rounded_corners_one_element.prototype.superclass = Custom_rounded_container; //alert(rounded_container.selector);//works //alert(rounded_container.color); //All_rounded_corners_one_element.prototype = new Custom_rounded_container(selector, color); All_rounded_corners_one_element.prototype = new Custom_rounded_container(); All_rounded_corners_one_element.prototype.constructor = All_rounded_corners_one_element;


Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
http://jsfiddle.net/shippuuden/pzrgL/6/
javascript code at end of the javascript section now.


Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
Opps sorry, all done now.
http://jsfiddle.net/shippuuden/pzrgL/8/


Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
Its working now.
I forgot to add
selector and color when calling the parent constructor.
Its working nowCode:Custom_rounded_container.call(this, selector, color);
Thanks for your help Paul.
Greatly appreciated.


This is where it is called with no further arguments.
Is it possible that you meant to use this instead?Code:Custom_rounded_container.call(this);
Code:Custom_rounded_container.call(this, selector, color);
Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
http://jsfiddle.net/shippuuden/pzrgL/11/
All working now.


Programming Group Advisor
Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
Car is to Carpet as Java is to JavaScript
Yep, thats what I changed it to.
and I figured out why it wasn't working with the superclass bit of code
needed to be afterCode:All_rounded_corners_one_element.prototype.superclass = Custom_rounded_container;
like so:Code:All_rounded_corners_one_element.prototype = new Custom_rounded_container(); All_rounded_corners_one_element.prototype.constructor = All_rounded_corners_one_element;
instead ofCode:All_rounded_corners_one_element.prototype = new Custom_rounded_container(); All_rounded_corners_one_element.prototype.constructor = All_rounded_corners_one_element; All_rounded_corners_one_element.prototype.superclass = Custom_rounded_container;
Code:All_rounded_corners_one_element.prototype.superclass = Custom_rounded_container; All_rounded_corners_one_element.prototype = new Custom_rounded_container(); All_rounded_corners_one_element.prototype.constructor = All_rounded_corners_one_element;
Thanks once again.
Now I can start creating parent methods and implementing them.
Bookmarks