The console.log() inside the onRendered() returns only null value. But if I paste the console.log() in the Meteor.setTimeout() function it work well. How can I solve this issue the Meteor like way.
What value you expect to be returned?
When onRendered is fired, there are no <option> s in that select yet.
Or I would not expect them to be inserted there yet.
If the render of the page is finished, than there is the “first value” selected in the dropdown menü. With the console.log() I want to print out the value, which is selected in the dropdown menü after loading the page.
I dont know why would somebody want to do that, when can simply use JS in template to get inital value from collection.
But with my limited knowledge, if I really had to code it from html, I would use _uihook on that select element and define insertElement function which would fire that console.log when executed first time.
The only thing I had to do, is to read the selected value from the dropdown menu on reload of the page and print it out in the browser console. It is only a test.
The reason you see “null” might be that you don’t wait for the data to be published from the server before displaying your list. So the list is initially empty.
To check that, put a console.log in your item helper to see what it returns.