Not logged in : Login

About: http://ods-qa.openlinksw.com:8896/proxy-iri/bd67f5d362358c7e119d709bd08a53722b1ef924     Goto   Sponge   Distinct   Permalink

An Entity of Type : schema:DiscussionForumPosting, within Data Space : ods-qa.openlinksw.com:8896 associated with source document(s)

AttributesValues
type
datePublished
publisher
described by
container of
mainEntityOfPage
author
position
  • #10
  • #9
dateModified
articleBody
  • And this is my JS code and live preview . Only points to highlight in my code comparing to the solved one by chris are: I used addEventListener instead of using the event handler as property. Being able to remove the listeners was what made me decide for it (even if it didn’t matter at this early stage ). Because of the previous point, I didn’t code the displayImage function specified in the guidelines. It was going to be only one line in there, and I was already using event function handlers. Too many functions for something that simple. But, I was able to see that setting up displayImage allow us to used it in a wide different set of events in case we want to improve our gallery; i.e. dragging a file to the page, display such picture and show another thumbnail at the bottom. I loved this assessment! it was challenging. I’m going to read again the “Introduction to events” section as well as the external links in there. I felt like it was a stepped curve of learning.
  • Hello! my code is the following: for( i=1; i<=5; i++) { var newImage = document.createElement(‘img’); newImage.setAttribute(‘src’, ‘images/pic’ + i + ‘.jpg’); function whatever(e) { displayedImage.setAttribute(‘src’, e.target.getAttribute(‘src’)); } newImage.addEventListener(‘click’, whatever); thumbBar.appendChild(newImage); } It seems to be working. My questions are the following: is there a preference for having the function ‘whatever’ inside the for loop or outside the for loop? mine is within the loop, but the solution code places it outside. Just want to know if there are any cases, and if so, what they are, in which one would be preferable. does the placement for the line ‘thumbBar.appendChild(newImage);’ matter, or can it be placed anywhere inside the for loop? I see that in the solution code, the function displayImage(imgSrc) is called before the function is defined, but I was under the impression that the code would crash if a function is called before it’s defined. can you please clarify the order of function calling and definition? And finally, just want to say that i found this assessment to be challenging and fun!
  • Hello! my code is the following: for( i=1; i<=5; i++) { var newImage = document.createElement(‘img’); newImage.setAttribute(‘src’, ‘images/pic’ + i + ‘.jpg’); function whatever(e) { displayedImage.setAttribute(‘src’, e.target.getAttribute(‘src’)); } newImage.addEventListener(‘click’, whatever); thumbBar.appendChild(newImage); } It seems to be working. My questions are the following: is there a preference for having the function ‘whatever’ inside the for loop or outside the for loop? mine is within the loop, but the solution code places it outside. Just want to know if there are any cases, and if so, what they are, in which one would be preferable. does the placement for the line ‘thumbBar.appendChild(newImage);’ matter, or can it be placed anywhere inside the for loop? I see that in the solution code, the function displayImage(imgSrc) is called before the function is defined, but I was under the impression that the code would crash if a function is called before it’s defined. can you please clarify the order of function calling and definition? And finally, just want to say that i found this assessment to be challenging and fun!
headline
  • "Image gallery" assessment
interactionStatistic
is topic of
is container of of
is object of
is subject of
Faceted Search & Find service v1.17_git55 as of Mar 01 2021


Alternative Linked Data Documents: ODE     Content Formats:       RDF       ODATA       Microdata      About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 08.03.3322 as of Mar 14 2022, on Linux (x86_64-generic-linux-glibc25), Single-Server Edition (7 GB total memory)
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2024 OpenLink Software