New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to set inputs from server #139
Conversation
|
Nice, now I can delete a whole lot of code. -Alex Brown On Apr 2, 2013, at 3:03 PM, Winston Chang notifications@github.com wrote:
|
|
The function It's important now to make sure that Checkbox groupCheckbox group, old style: <div class="control-group">
<label class="control-label" for="in_checkboxgroup">Checkbox group input:</label>
<input name="in_checkboxgroup" type="checkbox" value="option1"/>
label 1
<br/>
<input name="in_checkboxgroup" type="checkbox" value="option2"/>
label 2
<br/>
</div>Checkbox group, new style: <div id="in_checkboxgroup" class="control-group shiny-input-checkboxgroup">
<label class="control-label" for="in_checkboxgroup">Checkbox group input:</label>
<label class="checkbox">
<input type="checkbox" name="in_checkboxgroup" id="in_checkboxgroup1" value="option1"/>
<span>label 1</span>
</label>
<label class="checkbox">
<input type="checkbox" name="in_checkboxgroup" id="in_checkboxgroup2" value="option2"/>
<span>label 2</span>
</label>
</div>Radio groupRadio group, old style: <label class="control-label">Radio buttons:</label>
<label class="radio">
<input type="radio" name="in_radio" id="in_radio1" value="option1" checked="checked"/>
label 1
</label>
<label class="radio">
<input type="radio" name="in_radio" id="in_radio2" value="option2"/>
label 2
</label>Radio group, new style: <div id="in_radio" class="control-group shiny-input-radiogroup">
<label class="control-label">Radio buttons:</label>
<label class="radio">
<input type="radio" name="in_radio" id="in_radio1" value="option1" checked="checked"/>
<span>label 1</span>
</label>
<label class="radio">
<input type="radio" name="in_radio" id="in_radio2" value="option2"/>
<span>label 2</span>
</label>
</div> |
|
I've added the input updater functions, so that app authors can easily set input values from server.r. Example app here: Code here: |
|
Nice, thanks. I especially like the tab one. Presumably this also means that I can more directly and consistently use set value instead of the custom functions I have in my URL-> input code? Also, (I should really look at the code before asking this) what is the relationship between : Initial value of inputs as set by input constructors -Alex Brown On Apr 6, 2013, at 7:53 AM, Winston Chang notifications@github.com wrote:
|
|
Okay I have read the code; I think I can guess - there's an input$ at time 0, a stable input$ at some later time, and preferably none in between but maybe. When the slider is pulled, how many times might a function which depends upon every input except slider be executed? (Please be 1) Next question: do the input updaters trigger the change event on the input with the #id? I simulated input updaters by using renderUi with a single input in. However each time the input value was force changed the HTML for the input and its container were destroyed and recreated. This meant that the change events I registered for on the input didn't fire, and I never managed to get a 'create' event to work. It would be great if that's different with these new input updaters. -Alex Brown On Apr 6, 2013, at 7:53 AM, Winston Chang notifications@github.com wrote:
|
|
Yes, you can use The
You're right that there's an initial value of the input, then the server sends a message to set the inputs on the client side, then the client sends those updated input values to the server.
If an function doesn't depend on the slider input, then setting the value of the slider should have no effect. Setting the value of an input with
|
|
With the version of jslider presently included with Shiny, it appears not to be possible to remove and add back a slider, in order to change min/max/step. With the latest version of jslider on Github, it looks like you can do it, with something like this: $el = $("#in_slider")
$el.removeData('jslider')
$el.parent().find('.jslider').remove()
$el.slider({ from: 5, to: 40, step: 2.5, round: 1, skin: "round" });However, the latest Github version of jslider doesn't seem to like the HTML that Shiny generates. This doesn't work properly anymore: <input id="in_slider" type="slider" name="in_slider" value="15" class="jslider"
data-from="5" data-to="20" data-step="1" data-skin="plastic"
data-round="false" data-locale="us" data-format="#,##0.#####"
data-scale="|;|;|;|;|;|;|;|;|;|;|;|;|;|;|;|" data-smooth="false"/>I believe it would have to be something like this: <div class="layout-slider">
<input id="in_slider" type="slider" name="price" value="20" />
</div>
<script type="text/javascript" charset="utf-8">
jQuery("#in_slider").slider({
from: 5, to: 20, step: 1, round: 1,
format: { format: '#,##0.#####', locale: 'us' },
skin: "plastic"
});
</script> |
This is still a work in progress. It implements:
sessionargument toshinyServer(). This will allow us to pass things between the app code and the shinysession object.session$sendreceiveMessagefunctionreceiveMessageandgetValue)See example app at:
https://gist.github.com/wch/5266962