Commit 05b8b43a authored by Ivan Diaz's avatar Ivan Diaz
Browse files

First push making createChannels

parent 948c3d97
<template name="createChannel">
<!-- we need a forum in here -->
<form id="createChannels">
Created By: {{username}}
<input type="submit" id="userName" value="{{username}}" name="username"/>
Channel: <br>
<input type="submit" id="channelName" name="channel"/>
Date:<br>
<input type="submit" id="channelDate" name="date"/>
</form>
<br>
<input type="submit" value="Submit"/>
</template>
Template.createChannel.helpers({
channels: function() {
return Channels.find().fetch();
},
channelName: function(channelId) {
var channelObj = Channels.findOne(channelId);
return channelObj.name;
},
username: function() {
return Meteor.user().profile.name;
}
});
Template.createChannel.events({
'submit #channelName': function(e,t) {
var insUsername = $("#userName").val() //grab data from userName field
var channelName=$("#channelName").val(); //Same but for Channel Name field
var channelCheck = Channels.find({name: channelName});
if(channelCheck.length>0){ //Check to see if the channel length is greater than 0 and if its the same
alert("Channel exists, rename it");
} else { //Insert if it doesn't exist
Channels.insert({name: insUsername}), function(error){
if(!err) {
alert("SUCCESS!");
} else {
alert("Its messed up!");
alert(err);
}
}
}
}
//});
});
Template.createChannel.helpers({
channels: function() {
return Channels.find().fetch();
},
channelName: function(channelId) {
var channelObj = Channels.findOne(channelId);
return channelObj.name;
},
username: function() {
return Meteor.user().profile.name;
}
Template.createChannel.events(e,t) {
var insUsername = $("#userName").val() //grab data from userName field
var channelName=$("#channelName").val(); //Same but for Channel Name field
var channelCheck = Channels.find({name: channelName});
if(channelCheck.length>0) //Check to see if the channel length is greater than 0 and if its the same
alert("Channel exists, rename it");
} else { //Insert if it doesn't exist
Channels.insert{name: insUsername}, function(error){
if(!err) {
alert("SUCCESS!");
} else {
alert("Its messed up!");
alert(err);
}
}
}
}
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment