简体   繁体   English

使用Kendo UI for Mobile或JQuery滚动内容视图页面时,如何获取当前的div ID?

[英]How to get current div id when scrolling a content view page with Kendo UI for mobile or JQuery?

I'd like to get the id of the div displayed in the center of the screen. 我想在屏幕中央显示div的ID。

Basically, the user can see several events in the app scrolling down or up. 基本上,用户可以在应用程序中上下滚动查看多个事件。 I have a map at the top of the screen and I'd like that For each event the user is currently viewing (so the div in the list is in the middle of the screen) I'd like to grab its id (or data attribute) to reposition the map properly with a js function. 我在屏幕顶部有一个地图,我希望对于用户当前正在查看的每个事件(因此列表中的div位于屏幕中间),我想获取其ID(或数据)属性)以使用js函数正确地重新定位地图。

The js function is fine, but I don't know how to get the Id of a div displayed at the center of the list ( data-role="content" ). js函数很好,但是我不知道如何获取显示在列表中心的div的ID( data-role="content" )。 If Kendo UI mobile doesn't provide such functionnality, is it doable with jQuery ? 如果Kendo UI mobile不提供这样的功能,它是否可以使用jQuery?

EDIT: I'd like to give more precision to my issue: I'm looking to get the divs id, that are inside my div[data-role='content'], in a list. 编辑:我想更精确地解决我的问题:我希望在列表中获取位于div [data-role ='content']内部的divs ID。 So in within my view and my content block, when scrolling through the divs (displayed like a list) I'd like to get the id of the div currently displayed in my content div(1 div is the side of the content div). 因此,在我的视图和内容块中,当滚动div(以列表形式显示)时,我想获取当前显示在内容div中的div的ID(1 div是内容div的一面)。

Depends on what you need. 取决于您的需求。

You can use the view() method of the Application to retrieve the current View and the contentElement() method of the View to retrieve its content holder element (if you need it for DOM manipulation of its contents). 您可以使用应用程序的view()方法来检索当前的View,而可以使用View的contentElement()方法来检索其内容持有者元素(如果您需要它来对其内容进行DOM操作)。 If you need just the content element, you can use the content property . 如果只需要content元素,则可以使用content属性 Something like that for the current Application: 当前应用程序类似的内容:

var content = kendo.mobile.application.view().contentElement();

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

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