I'm creating multiple fullcalendar's on a single page and i would like to write a single event render callback such that it can read the options from the fullcalendar instance that it is called from/in, things like minTime and maxTime, not sure how to do this.
you can do something like this:
var minTime = $('#calendar').fullCalendar('option', 'minTime');
the option method isn't really documented, but it should work
Related
I have a model which is in autosave mode. When the user clicks on a button below code is executed.
I want the status to change and get saved and then it should execute the refresh function as the refresh functionality is dependent on the status value. But with the below code refresh function is getting executed before the new status is getting saved.
widget.datasource.item.status='inside';
refreshPanelWithColor();
What I really want to do is this to have the callback functionality but I can't use the saveChanges as it's only for manual save mode.
widget.datasource.item.status='inside';
widget.datasource.saveChanges(function() {
refreshPanelWithColor();
});
How to achieve callback functionality here without switching to manual save mode?
As how Markus Explains in his comment, this functionality is not available at the moment. You can of course use another solution which is using server scripting and reloading the datasource item. In order to achieve that, your client script should look similar to this:
var recordKey = widget.datasource.item._key;
var status = "inside";
google.script.run.withSuccessHandler(function(){
widget.datasource.item._reload(function(){
refreshPanelWithColor();
});
}).withFailureHandler(function(err){
console.err(err.toString());
}).updateDesiredRecord(recordKey, status);
And of course, you need to implement your server script being called from the client. It should look something like this:
function updateDesiredRecord(recordKey, status){
var record = app.models.MYMODEL.getRecord(recordKey);
record.status = status;
app.saveRecords([record]);
}
I'm not sure what your refreshPanelWithColor() function does but I hope you get an idea of what this solution intends to.
You just have to bind your function to datasource on after save event.
So I have setup a model/table that users will use as a project task list. I would like it so that when they change the Status (a field in the model) of an item to either Completed or Cancelled it is hidden.
That way they are only dealing with active entries. But I would also like them to be able to view these hidden (archived) items if needed.
I added the following code to the onAttach option of the table
var datasource = app.datasources.Projects;
datasource.query.filters.Status._notContains = 'Completed';
datasource.load();
And then I have a button with the following code so they can see hidden/archived items:
widget.datasource.query.clearFilters();
widget.datasource.load();
app.closeDialog();
var datasource = app.datasources.Projects;
datasource.query.filters.Status._contains = 'Completed';
datasource.load();
It works, but I feel like there might be a better/more elegant way to accomplish this. Especially since it looks like the app has to load then data, THEN filter it (which results in a slower load). (I think I might have some redundant code in there as well)
Also I feel like I am missing something with my syntax, because I can't get it to filter out Completed AND Cancelled.
Thank you for your help!
If you have a single page of items in the table and there aren't many items, then you can filter on the client side. For example, you can use a binding expression to add a "projectHidden" style to the row based on some logic and then use CSS to change the visibility of the row.
For your second code block, there is no reason to clear filters, load, set the filters and then load again. Just clear the filters, set the new filter, and call load. Also if you are manually controlling the query load, then you might want to uncheck the setting in the data source to automatically load data.
var datasource = app.datasources.Projects;
datasource.query.filters.Status._notEquals = 'Completed';
datasource.query.filters.Status._notEquals = 'Cancelled';
datasource.load();
I've looked around and tried a few things but I can't seem to get it to work. I want to be able to update the value stored in input$someVar from a bit of js code. What I need to on a certain element click, I need to update the input$someVar value. I know there are functions like "updateSelectInput()" but those are called from the server.
I can physically change the value of the data in the HTML that is used int he data attribute and that is displayed, but the server doesnt see this as a change and the input$someVar stays the same.
I have tried
var selectBind = Shiny.inputBindings.bindings[5];
selectBind.binding.setValue('#loc', newValue);
within an event handler, where #loc is the id of the input element, in hope that I could do it that way but this gives me an error.
Is there a way to do the functionality of "updateSelectInput()" within java script in the ui?
Yes, there is a way. Use the JavaScript function Shiny.onInputChange.
// change the value of an input
document.getElementById("id").value = "value";
// report the change to shiny
Shiny.onInputChange("id", "value");
sorry for my english.
The problem:
I have template "tempA" subscribe to "subs1". From tempA I create dynamically "tempB" (Blaze.render) then I have to subscribe to "sub1" again and wait for finish?
There is a way to use data from subs1 of tempA in tempB?
Thanks and sorry for my english again.
If your tempB is always inside tempA, then you can directly query the data, because collections are a reactive data source and will update helpers and UI reactively whenever new data comes in from server to client.
If you want to show a loading message or something similar, you can pass the subscription handler to tempB using Blaze.renderWithData and pass data, I think. When you subscribe save a reference to subscription handler like this,
Template.tempA.created = function () {
var template = this;
template.handler = template.subscribe('subs1');
}
Then you can pass this reference to tempB using Blaze.renderWithData like this,
Blaze.renderWithData(Template.tempB, template.handler)
Then you can check whether this subscription is ready in tempB using subscription handler's reference stored in Template.currentData().
I didn't try this and I have never used Blaze.renderWithData or Blaze.render, so I am not entirely sure if it works. Hope it helps.
I'm looking to make an element flash on screen when the underlying collection is updated.
It seems to me that it would make to have an equivalent of Template.my_template.rendered = function(){} which is fired every time the template is updated.
Ideally, this function would not fire the first time the template is rendered.
This is seems like such an obvious use case, am I missing something?
For Meteor < 0.8
You should use Template.myTemplate.created to do something for the very first time. From the docs Template.myTemplate.rendered is fired everytime there is a change including the first time. If you want to limit it to only the second time and changes after that (I'm guessing this is what you want), you have to write some custom logic. Currently there is no Meteor api that supports that.
For Meteor-0.8
It seems like this API underwent some backwards incompatible changes in Meteor-0.8.
There is an elegant way to achieve this as described Adaptation to the new Meteor rendered callback here. Bascially you should modify whatever function you are attaching to the variables inside your Template's javascript by calling a helper function once. For example,
var renderCount = 1;
var myHelper = function () {
console.log("rendered #" + renderCount);
renderCount++;
};
Template.myTemplate.myVariable = function () {
myHelper();
return this.name;
};
Hope this helps. There is also another alternative approach in that same repo. You might like that one.
There is no simple solution; more discussion here: https://groups.google.com/forum/#!topic/meteor-talk/iQ37mTP3hLg