Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically toggle split buttons for jQuery mobile listviews
    text
    copied!<p>I'm building a mobile app using jquery mobile. I'm using the listview control and so far it works fine. However I would like to display a split button (<a href="http://view.jquerymobile.com/1.3.0/docs/widgets/listviews/#list-split" rel="nofollow noreferrer">http://view.jquerymobile.com/1.3.0/docs/widgets/listviews/#list-split</a>) but only when a certain button is clicked. The use case is to enable / disable "delete mode", so that the delete icon appears next to the list element only after the button on the toolbar is clicked. I have a more or less working solution which is the following:</p> <pre><code>$('#editmode').live('click', function(e){ e.preventDefault(); $('.deletelog').toggle(); $('.deletelog:hidden').closest('li').removeClass("ui-li-has-alt"); $('.deletelog:visible').closest('li').addClass("ui-li-has-alt"); }); </code></pre> <p>The problem is, that for the first page load, even if the button is hidden by default:</p> <pre><code>&lt;a href="#" class="deletelog" style="display:none"&gt;Delete&lt;/a&gt; </code></pre> <p>I still have to add the data attributes data-split-icon and data-split-theme, which makes the first page load look in a way, that there's a space reserved for the button. As you can see from the above code, this is because of the class "data-split-theme". So if I toggle it, then it will disappar for the second toggle.</p> <p>Is there a better way to realize such a toggling split button? </p> <p>Thanks!</p> <p><img src="https://i.stack.imgur.com/h3Utm.png" alt="screenshot 1"> <img src="https://i.stack.imgur.com/BAmCX.png" alt="screenshot 2"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload