I have a dropdown menu with a submit function that executes, if any children from the dropdown is clicked. Now I want to prevent the submit function to a special li element, because there should be insert a tracking id in a popup iFrame.
With the following code it works so far on the first dropdown menu and prevent the submit function, but it wont work on all following dropdown's.
Maybe someone has a short solution for me?
<script type="text/javascript">
$(document).ready(function() {
$('.track').click(function(){
stopPropagation();
});
$('.dropdown li').click(function() {
document.getElementById('opt').value = $(this).data('value');
$('#options').submit();
});
$("#options").submit(function() {
if (confirm('are you sure?')){
return true;
} else {
return false;
}
});
});
</script>
<form name="" action="" method="post" id="options">
<input type="hidden" name="update" id="opt" value="">
<div id="item-select-option">
<div class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Options <span class="caret"></span></a>
<ul id="selector" class="dropdown-menu pull-right" role="menu">
<li data-value="paid"><a href="#">paid</a></li>
<li data-value="shipped"><a href="#">shipped</a></li>
<li class="track"><a href="tracking.php" class="trackbox" data-fancybox-type="iframe">track</a></li>
</ul>
</div>
</div>
</form>
eventis not defined.