Created
September 11, 2011 08:26
-
-
Save frequent/1209324 to your computer and use it in GitHub Desktop.
how to fire actionsheet from within a list element
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- not perfect yet, but going in the right direction ... --> | |
<!-- list element from within actionsheet should be triggered --> | |
<ul data-role="listview" data-inset="true" class="socialize"> | |
<li><a data-trigger="actionsheet" id="as1" href="#"><img src="iconSprite" class="ui-li-icon" alt="" />Favorite</a></li> | |
<li><a data-trigger="actionsheet" id="as2" href="#"><img src="iconSprite" class="ui-li-icon" alt="" />Hide</a></li> | |
</ul> | |
<!-- action sheets --> | |
<!-- need to be place outside list element, otherwise CSS is not working properly once activated--> | |
<div class="as1"> | |
<a data-role="button" href="#">Action 5</a> | |
<a data-role="button" href="#">Action 6</a> | |
<a data-role="button" href="#">Action 7</a> | |
<br/> | |
<a data-role="button" data-rel="close" href="#">Cancel</a> | |
</div> | |
<div class="as2"> | |
<a data-role="button" href="#">Action 5</a> | |
<a data-role="button" href="#">Action 6</a> | |
<a data-role="button" href="#">Action 7</a> | |
<br/> | |
<a data-role="button" data-rel="close" href="#">Cancel</a> | |
</div> | |
<!-- inside actionsheet.js --> | |
<!-- (try to) modify init-if to check for id and matching class-div --> | |
<!-- improve: trigger-class, sheet-id would allow to fire the same actionsheet from multiple locations --> | |
_init: function() { | |
var self = this; | |
this.content = ((typeof this.element.jqmData('sheet') !== 'undefined') ? $('#' + this.element.jqmData('sheet')) : $('.' + this.element.attr('id')) ) | |
.addClass('ui-actionsheet-content'); | |
<!-- also check for trigger within <ul> to avoid setting button markup to list items --> | |
if( this.element.parents( ':jqmData(role="content")' ).length !== 0 && this.element.parents( 'li' ).length != 1 ) { | |
this.element.buttonMarkup(); | |
} | |
<!-- fire on data-trigger="actionsheet"--> | |
$( ":jqmData(role='page')" ).live( "pagecreate", function() { | |
$( ":jqmData(trigger='actionsheet')", this ).each(function() { | |
$(this).actionsheet(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment