SitePoint Sponsor

User Tag List

Page 2 of 2 FirstFirst 12
Results 26 to 45 of 45
  1. #26
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,718
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by shippuuden View Post
    Cool, I didn't know that.

    But those two alerts are still not working.
    You'll need to update me with the code you are now using.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  2. #27
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have made few additional changes as well. It has fixed part of the problem.

    Total changes made:

    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;
    }
    Removed this code:

    Code:
    All_rounded_corners_one_element.prototype.superclass = Custom_rounded_container;
    Made change in All_rounded_corners_one_element function:

    Code:
    function All_rounded_corners_one_element(selector, color)
    {
    	alert("Inside All_rounded_corners");
    	Custom_rounded_container.call(this);
    	//this.superclass(selector, color);
    }
    Now

    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
    		
    	}
    }

  3. #28
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It has fixed what originally was not working but now what was originally working is now not working..lol

  4. #29
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,718
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by shippuuden View Post
    It has fixed what originally was not working but now what was originally working is now not working..lol
    Step by step, that's the way to do it. Give me a few moments to catch up. I've given up any hope of that jsfiddle being updated, and am attempting to match what you're doing (badly) with local code instead.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #30
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Opps sorry I'l update jsfiddle.

    First time I'm using it so forgot to update it.

  6. #31
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  7. #32
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,718
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by shippuuden View Post
    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

  8. #33
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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;

  9. #34
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,718
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by shippuuden View Post
    I don't think I'm using it correctly. I have done as you said.
    No, remove ALL of the scripting code from the HTML section. It doesn't belong there and more importantly, tries to execute before any of the other scripting code has even begun yet to exist.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  10. #35
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  11. #36
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    http://jsfiddle.net/shippuuden/pzrgL/6/

    javascript code at end of the javascript section now.

  12. #37
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,718
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by shippuuden View Post
    http://jsfiddle.net/shippuuden/pzrgL/6/

    javascript code at end of the javascript section now.
    Don't forget to remove it from the HTML section.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  13. #38
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Opps sorry, all done now.

    http://jsfiddle.net/shippuuden/pzrgL/8/

  14. #39
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,718
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by shippuuden View Post
    Opps sorry, all done now.

    http://jsfiddle.net/shippuuden/pzrgL/8/
    These lines do work now.

    Code:
    alert(rounded_container.color);//Does not work
    alert(rounded_container.temp_array); // Does not work
    It is expected behaviour for them to have undefined values when the Constructor is called with undefined values.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  15. #40
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its working now.

    I forgot to add

    selector and color when calling the parent constructor.

    Code:
    Custom_rounded_container.call(this, selector, color);
    Its working now

    Thanks for your help Paul.

    Greatly appreciated.

  16. #41
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,718
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    This is where it is called with no further arguments.

    Code:
    Custom_rounded_container.call(this);
    Is it possible that you meant to use this instead?

    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

  17. #42
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  18. #43
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,718
    Mentioned
    103 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by shippuuden View Post
    Hurrah, that's what we like to see
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  19. #44
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, thats what I changed it to.

    and I figured out why it wasn't working with the superclass bit of code

    Code:
    All_rounded_corners_one_element.prototype.superclass = Custom_rounded_container;
    needed to be after

    Code:
    All_rounded_corners_one_element.prototype  = new Custom_rounded_container();
    All_rounded_corners_one_element.prototype.constructor = All_rounded_corners_one_element;
    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;
    All_rounded_corners_one_element.prototype.superclass = Custom_rounded_container;
    instead of

    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;

  20. #45
    SitePoint Enthusiast
    Join Date
    Sep 2011
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks once again.

    Now I can start creating parent methods and implementing them.


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •