FullCalendar id field or function - fullcalendar

Is there a way to change the name of the id field that fullCalendar uses?
Like this:
$('myCal').fullCalendar('option', 'idField', 'myCustomIdField').
Or like this:
$('myCal').fullCalendar('option', 'idFunction', function(event){
return "prefix_" + event.id;
}).
thanks for advice

There is no idField function. the eventDataTransform option is indeed the only way to do this

Related

Get Geo location from Title element

I want to create a variable called Geo who'll show me the user location using the area code of a phone field in my form.
The area code HTML attached below.
I created this:
function flag(){
var getTitle = document.getElementsByClassName("selected-flag").getAttribute("title");
}
but it's not working.
Any suggestions?
The form's area code HTML
getElementsByClassName returns an array of elements. If you have only one element with such class name you can call:
function flag(){
var getTitle = document.getElementsByClassName("selected-flag")[0].getAttribute("title");
}
Otherwise I would suggest using unique id for the element and calling getElementById.
Eventually,
I got help and came up with this:
var el = document.querySelector('.selected-flag');
return el ? el.getAttribute('title') : undefined;

How can I do something like this in a template?: {{userScores.{{currentUserId}}.[0].score}}

This is working for me, but it is hard coded:
{{userScores.KxXJYDLvCvjk9nLwo.[0].score}}
I want to use Meteor.userId() in place of the hard coded id.
How can I do that?
Of course, this doesn't work;
{{userScores.Meteor.userId().[0].score}}
You can't do it directly in Blaze, you'll need a helper, ex:
{{score0}}
js:
Template.myTemplate.helpers({
score0() {
return this.userScores[Meteor.userId()][0].score;
}
});

Meteor: Using If condition to conditionally display templates when user clicks a navigation link

I have some templates corresponding to different places. I am using a navigation bar which has links to different places(Manali). I want the corresponding template to be displayed when a particular link is being clicked. I tried assigning id to each anchor link and use it inside the #if loop of the main file. Like below.
{{#if equals id 'badrinath'}}
{{> Manali}}
{{/if}
I created a helper function also for the comparison purpose.
UI.registerHelper('equals', function(a, b) {
return a == b;
});
But it isn't working. Can anyone suggest a solution. What property of the link can I capture and use it to display the template accordingly.
You sound to be looking for "routing" functionality.
You might be interested in Iron Router or Flow Router.
You can still implement your functionality without router, as it sounds still a simple situation as described. You are probably just lacking some event listeners to set your id variable to the correct value.
Probably something like:
<a data-role="changetemplate" href="targetTemplate">To Target Template</a>
var id = new ReactiveVar(); // add the reactive-var package
Template.myTemplate.helpers({
id: function () {
return id.get();
}
});
Template.myTemplate.events({
"click a[data-role='changetemplate']": function (event) {
event.preventDefault();
id.set(event.currentTarget.href);
}
});

Coalesce a value in Meteor Jade

In a template, I do this
if description
p.editable= description
else
p.editable
| No description. Click to edit.
I wonder if there's a way to coalesce a value like in JavaScript:
p.editable #{description || 'Click to edit'}
But this is incorrect syntax in Jade
Unfortunately jade doesn't support exactly what you're trying to achieve.
Best way would be to create a variable in your template like so:
- var desc = description || "Click to edit"
p.editable #{desc}

Is it possible to reference a Template name dynamically and call onRedered on it

Currently I have the following in a package:
Template.layout.onRendered(function() {
//Do stuff when the template called "layout" is rendered
});
But I would like to make the template name user configurable. Something like:
var templateName = 'customLayout';
Template.{templateName}.onRendered(function() {
//Do stuff when the template called "customLayout" is rendered
});
Any help in the right direction would be great!
In JavaScript you can use the square brackets syntax to do that:
Template['customLayout'].onRendered( [...] )
'customLayout' above can be an arbitrary expression.
From Meteor 0.8.2, you can write this:
var myTemplate='foo';
{{> UI.dynamic template=myTemplate}}
https://www.discovermeteor.com/blog/blaze-dynamic-template-includes/

Resources