When rebuilding a Bootstrap Slider, it does not get the value of the current position again

2

When rebuilding a Bootstrap Slider, it does not get the value of the current position again.

This is the code:

//SlideStop función para obtener el valor de la posición actual

$("#ex19").on("slideStop", function (slideEvt) {
  valopt = $("#ex19").slider("getValue");
    if (valopt == 1) {
      rslider(); // llama la función cuando la posición actual es 1                 
    }
    else if (valopt == 4)
    {
      alert('Hello'); // muestra el mensaje cuando la posición actual es 4
    }             
});

// Function para reconstruir slider

function rslider(){
  $("#ex19").slider('destroy');
  $("#ex19").slider({
      ticks: [1, 2, 3, 4],
      ticks_labels: ['1', '2', '3', '4'],
      ticks_snap_bounds: 1,
      tooltip: 'hide',
      min: 1,
      max: 4,
      value: 1,
      step: 1
  });
  $("#ex19").slider('refresh');
}

//HTML aspx

<div id="content">
    <form id="form1" runat="server">
        <div id="slider">
            <input id="ex19" type="text" 
                data-provide="slider"
                data-slider-ticks="[1, 2, 3]"
                data-slider-ticks-labels='["short", "medium", "long"]'
                data-slider-min="1"
                data-slider-max="3"
                data-slider-step="1"
                data-slider-value="1"
                data-slider-tooltip="hide" 
                runat="server" />
        </div>
    </form>
</div>

When I slide the Slider and it stays in one position before rebuilding it, it works. But once it is rebuilt, obtaining the current position does not work.

    
asked by José 15.11.2016 в 17:37
source

1 answer

0

If you are using JqueryUI next to Bootstrap there may be a namespaces conflict. If that is the case, you could download a customized version of JqueryUI that does not include the library's own slider and that is only the Bootstrap .

    
answered by 17.11.2016 в 21:49