mirror of
https://github.com/rstudio/shiny.git
synced 2026-02-11 07:05:18 -05:00
The shiny:inputchanged event
This commit is contained in:
@@ -72,8 +72,9 @@ function initShiny() {
|
||||
|
||||
var inputBatchSender = new InputBatchSender(shinyapp);
|
||||
var inputsNoResend = new InputNoResendDecorator(inputBatchSender);
|
||||
var inputsRate = new InputRateDecorator(inputsNoResend);
|
||||
var inputsDefer = new InputDeferDecorator(inputsNoResend);
|
||||
var inputsEvent = new InputEventDecorator(inputsNoResend);
|
||||
var inputsRate = new InputRateDecorator(inputsEvent);
|
||||
var inputsDefer = new InputDeferDecorator(inputsEvent);
|
||||
|
||||
// By default, use rate decorator
|
||||
var inputs = inputsRate;
|
||||
|
||||
@@ -251,6 +251,25 @@ var InputDeferDecorator = function(target) {
|
||||
};
|
||||
}).call(InputDeferDecorator.prototype);
|
||||
|
||||
var InputEventDecorator = function(target) {
|
||||
this.target = target;
|
||||
};
|
||||
(function() {
|
||||
this.setInput = function(name, value, immediate) {
|
||||
var evt = jQuery.Event("shiny:inputchanged");
|
||||
var name2 = name.split(':');
|
||||
evt.name = name2[0];
|
||||
evt.inputType = name2.length > 1 ? name2[1] : '';
|
||||
evt.value = value;
|
||||
$(document).trigger(evt);
|
||||
if (!evt.isDefaultPrevented()) {
|
||||
name = evt.name;
|
||||
if (evt.inputType !== '') name += ':' + evt.inputType;
|
||||
this.target.setInput(name, evt.value, immediate);
|
||||
}
|
||||
};
|
||||
}).call(InputEventDecorator.prototype);
|
||||
|
||||
var InputRateDecorator = function(target) {
|
||||
this.target = target;
|
||||
this.inputRatePolicies = {};
|
||||
|
||||
Reference in New Issue
Block a user