Opened 13 years ago

Closed 13 years ago

Last modified 10 years ago

#270 closed defect (invalid)

fromScript borks slideshow; doesn't use _this in callback properly

Reported by: anonymous Owned by: anonymous
Priority: high Milestone:
Component: Widgets Version:
Keywords: slideshow, fromscript Cc:
Blocked By: Blocking:

Description

Attempting to use slideshow in a fromScript call, but it callback function isn't using "_this" properly. The problem callback function is under

-SlideShow?.js

this.backgroundImageLoaded = function() { ...

var callback = function(){ alert('in fromscript, I will never get called'); _this.endTransition(); };

... }

Here's a use case that I inserted into test_SlideShow.html

<script>

var summary = document.createElement("div"); dojo.html.body().appendChild(summary); var test = dojo.widget.fromScript("SlideShow?", {transitionInterval:"700", imgUrls:["images/2.jpg","images/1.jpg"],delay:"7000", imgWidth:80, imgHeight:80, src:"images/1.jpg"},summary);

</script>

Using 0.21 kitchen sink build.

Attachments (1)

test_slideshow2.html (1003 bytes) - added by bill 13 years ago.
working example

Download all attachments as: .zip

Change History (5)

comment:1 Changed 13 years ago by bill

Huh? It seems like your defining a variable called "callback" but you're never referencing it anywhere. Can you give a more complete example?

comment:2 Changed 13 years ago by Brian Lucas

Thanks Bill.

Sure, I'll include a full example of modified test_SlideShow.html. Copy and paste this into the demo directory (with the images/1.jpg; images/2.jpg made available) and you should notice that the "<img>" Slideshow instantiation works fine, but the "fromScript" Slideshow instantiation bombs out -- meaning that the first image displays but the next images do not.

<title>Slideshow Widget Demo</title>

<script type="text/javascript"> var djConfig = {isDebug: true}; </script>
<script type="text/javascript" src="../../dojo.js"></script>


<script language="JavaScript" type="text/javascript">
	dojo.require("dojo.widget.*");
	dojo.require("dojo.event.*");
	dojo.require("dojo.widget.html.LayoutPane");
	dojo.require("dojo.html");
	dojo.require("dojo.style");
	dojo.require("dojo.fx.html");

	dojo.require("dojo.widget.SlideShow");
	var summary = document.createElement("div");
	dojo.html.body().appendChild(summary);
	var test = dojo.widget.fromScript("SlideShow", {transitionInterval:"700",	imgUrls:["images/2.jpg","images/1.jpg"],delay:"7000", imgWidth:80, imgHeight:80, src:"images/1.jpg"},summary);

</script>

<img dojoType="SlideShow" 
	imgUrls="images/1.jpg;images/2.jpg;images/3.jpg;images/4.jpg;images/5.jpg;images/6.jpg" 
	imgCaptions="Test1;test2;test3;test4;test5;test6"  
	imgLinks="Test1;test2;test3;test4;test5;test6"  	
	transitionInterval="700" 
	delay="7000" 
	src="images/1.jpg"/>

I believe this is due to the "_this" being lost somewhere, more specifically in "this.backgroundImageLoaded" under SlideShow?.js.

Please let me know if it works for you. I've tried on multiple builds, most recently 0.21.

Changed 13 years ago by bill

Attachment: test_slideshow2.html added

working example

comment:3 Changed 13 years ago by bill

Resolution: invalid
Status: newclosed

If you gvet rid of the quotes around "700" and "7000" it will work. I attached a working example.

Unfortunatly dojo doesn't have type-checking or type-coercion when you create a widget from a script. Remember that 1000+700==1700, but 1000+"700"=="1000700". Thus it would have taken years for the image to change.

comment:4 Changed 12 years ago by (none)

Milestone: 0.2.1release

Milestone 0.2.1release deleted

Note: See TracTickets for help on using tickets.