4

Sample fiddle of my problem: http://fiddle.jshell.net/FS8rj/

I have a few places where I don't want users to be able to delete something out of a collapsible using an icon -- so I want to hide this icon completely.

It seems jQuery Mobile puts padding for each element in the collapsible so that elements don't clump together.

I tried refreshing the entire list-view, but jQuery Mobile doesn't recognize that I've hidden an element with jQuery and it continues to add the padding regardless. I know one workaround is to disable the icon rather than hide it, but I don't want to leave it greyed out on the screen at all.

Is it possible to disable this without overwriting it with more css or similar methods?

4

3 回答 3

4

jQuery Mobile 添加ui-li-has-altli拆分按钮。您只需要删除该类并在再次显示该按钮时将其添加回来。

演示

$('li').removeClass('ui-li-has-alt');

编辑:用于从parent.closest()中删除类li

$('.hide').hide().closest('li').removeClass('ui-li-has-alt');
于 2013-07-08T22:48:25.433 回答
2

http://fiddle.jshell.net/njAt4/

只需将 a 标签与您的删除类一起包装在 div 中,然后它就可以按您的意愿工作。

<div class="delete">
   <a href="#" data-rel="popup" data-mini="false" data-position-to="window" data-icon="delete"></a>
</div>

这将完全删除该节点上的删除图标。

于 2013-07-08T18:43:39.920 回答
1

http://fiddle.jshell.net/YGCQM/

解决方案是将“ui-li-count”的正确css属性覆盖为10px。当有按钮时,它会更改为 53px,无论是否隐藏。

if (reportViewModel.hasDisabledExpenses()) {
    $('.delete').hide();
    $('.delete').parent().find(".ui-li-count").css("right", "10px");
}
于 2013-07-08T19:23:41.477 回答