im setting both values of my range-slider with the following line: $('...').slider( 'values', [ 0, 10000 ] ); Now i have the problem, that this line triggers two times the change( event, ui )-event. Is there a workaround to only trigger it one time? Or is there an other event that i could use / create to get the problem solved?
I just want to avoid sending two times an ajax-request of a huge amount of data
thanks for your replies!
Peter
An article here for you: Setting slider value without triggering change event
If you apply something like this when you're setting values in script, you could call your ajax request outside of the change handler and after you set your slider values.
Related
I have grid and want to apply default sorting on it, I am getting parameters from an API. My flow is as below.
Store.sort(sorters), where this code do load operation and after refreshing grid, It fires an event sortchange event on first load. How can i prevent it?
Update: I tried sortOnLoad:false. But, it is not working.
in sortchange event there is one parameter called column
so,when it will called just check column.hasFocus. if it will true that means user sort from grid header.
and if it return false that means it's called by loading or removing data.
Hope, this information will help you..:)
probably quite easy question. I am not too familiar with Javascript embedded in Shiny items and cannot get this one right
I have a gVis table and the only way to get the row selected is to use a js listener. My listener is quite easy, assigning a row to a variable (here sustable)
sussimilar_click <- sprintf("var sustable = chart.getSelection()[0]['row'];
Shiny.onInputChange('sustable', sustable);")
what i want to achieve is to alter the table beneath - changing the value from TRUE to FALSE and the other way with every click
so i have a simple observer
observe({input$sustable
values$datAll1[input$sustable+1,3] <- !values$datAll1[input$sustable+1,3]
})
As you might expect it changes the way i need it, but it triggers only on a value change - so if i click twice on the same item it would not fire the 2nd event.
How can i get the trigger on every click? Or maybe should i change the listener without passing the value to observer (if so, how? is there any Shiny.onInput without change?)
The solution i use for that is to add a second input, namely input$trigger, which i add to the javascript part. Assigning him a random number ensures that he fires on every click and triggers the code of the observer in the server function.
Shiny.onInputChange('sustable', sustable);
Shiny.onInputChange('trigger', Math.random());
and then let the server code listen on that:
observeEvent(input$trigger, {
values$datAll1[input$sustable+1,3] <- !values$datAll1[input$sustable+1,3]
})
I found the answer combining js script with shinyjs
i added onclick event to the gvis table that reads the listener and then changes the data
to the ui:
useShinyjs(),
extendShinyjs(text = jsCode),
and to the server:
onclick("sussimilar", {
values$datAll1[input$sustable+1,3] <- !values$datAll1[input$sustable+1,3]
})
of course BigDataScientist' answer is equally good as it calls for creating another entity just as mine
note: sussimilar here is the gVisTable name, not any particular function
I am using jquery.dataTables.yadcf.js and //cdn.datatables.net/1.10.6/js/jquery.dataTables.js with sAjaxSource
I'm trying to use external filters that triggers several columns to a pre-selected filter at once. So you click a button and there, three columns are picked out so you don't have to go in each drop down.
But the way I'm doing it seems wrong, because I'm seeing two JSON requests instead of one every time they're triggered.
All I have in my script is
function doTrigger(){
yadcf.exFilterColumn(oTable, [[0,"zero"],[1,"one"]]);
$("#yadcf-filter--oTable-" + 1).val("one");
oTable.fnDraw();
}
Your code should look like this: I haveadded third argument true, its undocumented, but needed when calling the exFilterColumn after table finished loading
function doTrigger(){
yadcf.exFilterColumn(oTable, [[0,"zero"],[1,"one"]], true);
}
The rest of your code is not needed at all...
I've created an image map using the code:
$('img').mapster({
staticState: true
})
All areas are selected at once and visible. Is there any way, any method I could hide/disable some areas so that they wouldn't be visible ? I would like to filter areas on some conditions.
I know that I can remove 'area' tag or href atribute from javascript level and then call the above code once more (once again recreate imagemapster) but is there any more elegant and smarter way ? Maybe there is some build-in plugin solution but I couldn't find that.
Thank you for any help.
Kind Regards
Marcin
I suggest you to change to
$('img').mapster({
selected: true,
isSelectable: false, // can't change of state by simple click
isDeselectable: false, // can't change of state by simple click
})
you can still bind the onClick callback on all the areas.
once you decide which areas you don't want, you can set the individual state via
$("#id_of_area").mapster('set',false);
or from the map id
$("img").mapster('set',false,'key or string of keys to deselect');
it seems staticState is just for show, and doesn't set everything to a selected state... ( I tried some combinations and had weird results like making it darker like on selected+highlight)
Something like this http://jsfiddle.net/Wvzgj/529/
I have a problem with initialization of dynamically filled dropdowns in jQuery.
Basically, I have function fillCityList and it makes AJAX call to fill the cities by the passing country.
Because this is used in Edit form, I have a default City value in id_cityHidden field.
Actually the code below works well.However, because fillCityList takes long time to fill the city list, while default city is selected, the city list may not be ready.
$(document).ready( function() {
fillCityList(1);
$('#city').val($("#id_cityHidden").val());
});
I know there is a solution like "call function at complete stage of AJAX call" but I just need it during initialization.
One solution might be setting a timeout or delay between fillCityList and
$('#city').val($("#id_cityHidden").val()) however, it is not a good solution of course.
What is the best way to do this ?
Thanks
I would suggest you build your ajax to use the 'complete' function, then update the value.
http://api.jquery.com/ajaxComplete/