HELP!Check this code

Check This code.
(main.htm)

   <select name="addcollege" class="addcollege" id="addcollege" value="addcollege" font-size:18px>
                          <option value="">--Select College--</option>
                  <option value="NIT-Warangal" id="NIT-Warangal">NIT-Warangal</option>  {{#if show}}Rank: {{show.rank}} {{/if}}

client/app.js

Template.table.events({ 'change #addcollege': function(event, template){ var selectValue = $("#addcollege").val();  (IN HELPERS)  'show': function() {

return College.find({'name':selectValue}).fetch(); }

Common.js

College = new Mongo.Collection('colleges');    if (Meteor.isServer) {  if (College.find().count() === 0) {College.insert({
rank:10,
name: "NIT-Warangal" , ) }

I was struggling in selecting the select options…i tried to use session variables…tried to retrieve but just can’t figure it out…My intention is…in the first table…if i select NIT-Warangal…it should show the components…See the client app.js… i use {{#if show}}…in show() function…i retrieved the value of the college… n i displayed as {{show.rank}} … but ain’t working…Can u please spare 5 minutes n make it working please…

if you actually want help you’ll do the work and ask one specific question. When providing code, provide a minimum amount…

2 Likes

Done…Check the question now bro! :slight_smile:

Hey good work with the code. Thought hard to read because of identation, but ok.

Now if I understand your question properly the problem is that the “show” variable is not working? That’s because you’re deifining “show” in .events(). But it should be definer in -helpers(). does that help?

I used show in helpers…o

For simplicity…i mixed both :confused: …Help!

ah hard to concentrate on your code.

when you Collection.find().fetch() and it finds no results, the result is returned empty array []. And [] !== null. So rather you need to return

_.isEmpty(C.find().fetch())

or of course just return C.find().fetch() !== []

Does this help?

I already fixed his meteorpad

1 Like