HELP!Check this code


#1

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…


#2

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


#3

Done…Check the question now bro! :slight_smile:


#4

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?


#5

I used show in helpers…o

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


#6

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?


#7

I already fixed his meteorpad