Tuesday, 15 April 2014

html - Dojo dom-construct.place() not working -



html - Dojo dom-construct.place() not working -

i'm writing widget takes kid <img> tags, grabs src attribute, , should create unordered list kid list elements having background aforementioned sources. however, when create list elements , tell dojo place them within master <ul>, end outside. widget 3rd in chain, represented here:

+ imagebox ++ animimagebox ++ slideimagebox +++ animslideimagebox (tba)

master list creation:

buildrendering : function(){ this.inherited(arguments); // create slidebox <ul> this.slideholder = domconstruct.create('ul', { classname : 'imagebox-slide' }, this.domnode, 'first'); }

this block _lazyload method. it's defined in root imagebox class, , overridden here, called within postcreate():

var self = this; query('img', this.domnode).foreach(function(image){ // each found image, force src attribute our class-wide array var src = domattr.get(image, 'src'); self.images.push(src); // create <li> slide block var li = domconstruct.create('li', { classname : 'slide' }, self.slideholder); // destroy <img /> element domconstruct.destroy(image); });

overview of class structure/method calls:

imagebox.js

buildrendering(): - creates preloader postcreate(): + calls _lazyload extract image data, load, show progress, etc.

slideimagebox.js (the 1 i'm having issues with)

buildrendering(): - calls superclass method, , creates <ul> element, placing this.domnode postcreate(): - calls superclass postcreate() method (via this.inherited(args)) _lazyload(): - overridden completely, called correctly tested various log() calls.

expected result

<ul class="imagebox-slide"> <li class="slide"><!--content --></li> <li class="slide"><!--content --></li> <li class="slide"><!--content --></li> </ul>

results

<ul class="imagebox-slide"></ul> <li class="slide"><!--content --></li> <li class="slide"><!--content --></li> <li class="slide"><!--content --></li>

at every step can log() nodes, know exist, domconstruct.create() line isn't putting them node. i've dealt dojo more once, maybe has inheritance somewhere?

maybe it's late , need fresh pair of eyes, or else @ work here?

edit

@davidmcmullin, place phone call having issues implicitly called in create, sorry didn't emphasize point.

@frode, requires inheritance 2 other .js files, haven't used fiddler plenty know how set up, i'll though.

@stephen, it, turns out, somehow, creation order off, though log() statements telling me wasn't, , thought had tried that... i'll have refactor bit accommodate methods called in superclass glad it's working now. set reply , i'll accept.

can't see wrong code. think ought work. placement order of various nodes.

have tried running buildrendering code in postcreate instead? looks <ul> element beingness created after <li>'s have been placed (just guess) - seek changing placement parameter 'first' 'last' see if appears after <li>'s, if beingness run after <li>'s created (just hunch, stabbing in dark looks fine me).

if works might worth having position of this.inherited(arguments); within methods. maybe seek moving end of buildrendering (after code create <ul>).

html dom dojo

No comments:

Post a Comment