I got a collapsible-set with a few collapsible-items. Every collapsible-item shout have a few buttons with an onclick event:
<div id="List" data-role="collapsible-set" data-theme="b" data-content-theme="d">
<div id='ListItem' data-role='collapsible' data-content-theme='b' data-collapsed='false'>
<h3>Title
<div style='float:right;'>
<input type='button' data-theme='b' value='Settings' data-mini='true' data-inline='true' data-icon='gear' data-icon-pos='top' onclick='test(43);'/>
<input type='button' value='Delete' data-theme='b' data-mini='true' data-inline='true' data-icon='delete' onclick='test(45);' class='splitButtonClicked'/>
</div>
</h3>
CONTENT
</div>
</div>
function test(value){
alert(value);
return false;
}
The onclick event should call a function with one or more parameters. The event works well, but after the event the listview item collapse. This should not happen!
How can I interrupt the collapse?
Regards
Inline javascript like
onclick=...should not be used withjQuery Mobile. To prevent this problem click event must be bound to the button and prevented from propagation to lover levels.Here’s a working
jsFiddleexample: http://jsfiddle.net/Gajotres/z3hsb/Code example:
If you want to find out more about this topic and more take a look at this ARTICLE, to be more transparent it is my personal blog. Or it can be found HERE. One more thing, in my article I have stated that developers should not use bind/live/delegate to bind an event, but here we MUST use bind because of a way how it works / interacts with
data-role="collapsible-set", functionsliveandonwill not work here.