Opened 16 years ago

Closed 16 years ago

Last modified 12 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:


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


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


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);


Using 0.21 kitchen sink build.

Attachments (1)

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

Download all attachments as: .zip

Change History (5)

comment:1 Changed 16 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 16 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">

	var summary = document.createElement("div");
	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);


<img dojoType="SlideShow" 

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 16 years ago by bill

Attachment: test_slideshow2.html added

working example

comment:3 Changed 16 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 15 years ago by (none)

Milestone: 0.2.1release

Milestone 0.2.1release deleted

Note: See TracTickets for help on using tickets.