Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5850223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T13:06:39+00:00 2026-05-22T13:06:39+00:00

I’ve started to learn the dojo Toolkit and i like it so far, it

  • 0

I’ve started to learn the dojo Toolkit and i like it so far, it seems to me easier to understand than jquery/prototype JS. I’m still new at it (and in javascript) and while there is a plethora of docs available on the net i don’t really understand how to achieve simple tasks like making a hidden visible with dojo. So to the problem:

the html

<!-- the numder in id="comment" and in href="javascript:display_comments('')" is the post_id that i want the comments to be fetched for -->

<div class="comments">
    <a id="comment8" href="javascript:display_comments('8');">comments</a>(21)
</div>
<div style="visibility: hidden;" id="display_comments8">

</div>

<div class="comments">
    <a id="comment7" href="javascript:display_comments('7');">comments</a>(13)
</div>
<div style="visibility: hidden;" id="display_comments7">

</div>

<div class="comments">
    <a id="comment15" href="javascript:display_comments('15');">comments</a>(20)
</div>
<div style="visibility: hidden;" id="display_comments8">

</div>

the javascript

function display_comments(id) {
    divid = 'display_comments'+id;
    var element = document.getElementById(divid);
    if(element.style.visibility == 'hidden') {
        element.style.visibility='visible'
    }else if(element.style.visibility == 'visible') {
        element.style.visibility='hidden';
        element.innerHTML='';
    }
}

The parameter for display_comments() in the post_id which then is merged with the words ‘display_comments’ so to know which div to make visible. How can this be achieved in dojo?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T13:06:40+00:00Added an answer on May 22, 2026 at 1:06 pm

    Basically what you want to do here is automate things a bit right? If you attribute your links either by id, like i use below, or some other way (non validatable properties or html5 data-attributes) then you can use dojo.query to find all the nodes in your container and attach an event to them. I gave you a link to the dojo.query syntax page in case you wanted to make your query syntax more specific.

    After looping through all the a nodes in container and attaching a click event with a handler that passes the node’s id (the dojo.partial stuff), you just need to handle the click event. The toggle display uses dojo core to change and modify the style of the node – pretty simple.

    Based on your example this is how I would change your code.

    There are a lot of ways you could achieve these results. Personally, I would create templated widgets. Since this code looks repetitive, you could dojo.declare a comment class and dojoattachevents to the links and dojoattachpoint to the hidden node. This way you wouldn’t have to dojo.query or dojo.byId since widget would wire all that up for you. You could create one for each and use class syntax to handle the logic.

    <div id="container">
    <div class="comments">
        <a id="8">comments</a>(21)
    </div>
    <div style="visibility: hidden;" id="display_comments8">
    
    </div>
    
    <div class="comments">
        <a id="7">comments</a>(13)
    </div>
    <div style="visibility: hidden;" id="display_comments7">
    <div>
    

    dojo.query reference

    dojo.query("#container a").forEach(function(node) {
    

    dojo.connect reference

    dojo.partial reference

    dojo.connect(node, 'onclick', dojo.partial(toggleDisplay, node.id));
    });
    

    dojo.byId reference
    dojo.style reference

       function toggleDisplay(node) {
            var hiddenNode = dojo.byId('display_comments' + node);
            var display = dojo.style(hiddenNode).visibility === 'visible' ? 'hidden' : 'visible';
            dojo.style(hiddenNode, {
                visibility: display
            });
        }
    

    Working Example
    jsfiddle example

    Books

    we have dojo the definitive guide and mastering dojo and getting startED with dojo.
    PS all these books are outdated and the best information is found on the test pages/the irc #dojo chat room/and the reference guides.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.