Hey people out there !
I’m quit new to the meteor 1.4.1.3 and still struggling
I need help in refactoring my code i written so far, if someone has the time.
next weird point for me i use the materialize:materialize package and want to add a datepicker to my form, but the initialization:
$(function() {
$('.datepicker').pickadate({
close: 'submit',
onStart: function() {
var date = new Date()
this.set('select', [date.getFullYear(), date.getMonth(), date.getDate()]);
}
});
});
only works as inline<script>
inside my template, but i want to have an external index.js file that imports the template file, but it’s not working. the datepicker disappear when i refresh the page.
next point at the moment i’ve code duplications 'cause i don’t know how to access a helper function on different templates:
// add-food.js
import dateFormat from 'dateformat'
import './add-food.html'
Template.addFood.helpers({
'getCurrentTime'(){
let time = new Date()
let currentTime = dateFormat(time, 'h:MM TT')
return currentTime
}
});
// add-symptoms.js
import dateFormat from 'dateformat'
import './add-symptoms.html'
Template.addSymptoms.helpers({
'getCurrentTime'(){
let time = new Date()
let currentTime = dateFormat(time, 'h:MM TT')
return currentTime
}
});
//index.js
import { Template } from 'meteor/templating'
//import dateFormat from 'dateformat'
import './layout.js'
import './pages/add-food.js'
import './pages/add-symptoms.js'
$(function() {
$('.modal-trigger').leanModal()
});
/*Template.body.helpers({
'getCurrentTime'(){
let time = new Date()
let currentTime = dateFormat(time, 'h:MM TT')
return currentTime
}
});*/
I tried using the Template.body. but it’s not working. How do I sum up the code?