简体   繁体   English

Dojo滑块:动态更新值

[英]Dojo slider: update value dynamically

I am building an application where the user browses certain objects by scrolling and zooming. 我正在构建一个应用程序,用户可以通过滚动和缩放浏览某些对象。 To change the zoom level I have successfully implemented a "dijit.form.HorizontalSlider" object. 要更改缩放级别,我已经成功实现了“ dijit.form.Horizo​​ntalSlider”对象。 Every time the user changes the position of the silder, I can catch the "onChange" call and do something with that. 每次用户更改贴图机的位置时,我都可以捕获“ onChange”调用并对此进行操作。

However, the user can also zoom-in by double clicking inside the view zone, at which point the slider should change position automatically to reflect the new zoom level. 但是,用户也可以通过在视图区域内双击来放大,这时滑块应自动更改位置以反映新的缩放级别。

My question is the following: what function or method should I call in my javascript to update the position of a dojo silder ? 我的问题如下:我应该在JavaScript中调用什么函数或方法来更新dojo silder的位置?

Here is the code that creates the silder object: 这是创建silder对象的代码:

var zoomSlider = new dijit.form.HorizontalSlider({
         name: "zoom_slider",
         id: "zoom_slider",
         value: 0,
         minimum: 0,
         maximum: 19,
         discreteValues: 20,
         intermediateChanges: false,
         style: "width: 160px;",
         onChange: function(value) {
            brwsr.view.zoomTo(value);
         }
     },
     "zoom_slider");
navbox_silder.appendChild(zoomSlider.domNode);

First you need to define an id property in your example's config object like id:'zoom_slider1' to get a hold of the widget and then access it like this: 首先,您需要在示例的配置对象中定义一个id属性,例如id:'zoom_slider1' ,以保留该小部件,然后按以下方式对其进行访问:

dijit.byId('zoom_slider1').attr('value',whateverthenewvalueis);

See Dijit Basics . 参见Dijit基础

After DanMan's idea of adding an "id" field to the slider creation code, I dug into dojo's javascript files and found the appropriate undocumented internal method. 在DanMan想到在滑块创建代码中添加“ id”字段之后,我研究了dojo的javascript文件并找到了适当的未记录内部方法。 This is it: 就是这个:

dijit.byId("zoom_slider")._setValueAttr(newvalue);  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM