I am attempting to filter out hidden form values from the jQuery output of serialize(). The invisible inputs/selects are nested within div.ui-tabs-hide elements. I need to include all input and select elements within divs that do not have the ui-tabs-hide class, while excluding those within divs with the ui-tabs-hide class in a single form.
Currently, my attempt includes all form elements, but I suspect my selectors are not correctly specified.
Below is the code snippet that reproduces the issue:
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var formdata = $("#outboundcall:not(.ui-tabs-hide input, .ui-tabs-hide select)").serialize();
console.log(formdata);
});
</script>
<meta charset="utf-8" />
<title>JS Bin</title>
</head>
<body>
<form id="outboundcall">
<div class="content">
<div class="tabs ui-tabs ui-widget ui-widget-content ui-corner-all">
<ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all">
<li class="ui-state-default ui-corner-top ui-tabs-selected ui-state-active">
<a href="#tabs-1">Credit Card</a>
</li>
<li class="ui-state-default ui-corner-top">
<a href="#tabs-2">Cheque</a>
</li>
<li class="ui-state-default ui-corner-top">
<a href="#tabs-3">Direct Debit</a>
</li>
</ul>
<div id="tabs-1" class="ui-tabs-panel ui-widget-content ui-corner-bottom">
<input type="hidden" value="1" name="lead-payment-method" />
</div>
<div id="tabs-2" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide">
<p>Cheque functionality is not currently available.</p>
</div>
<div id="tabs-3" class="ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide">
<input type="hidden" value="3" name="lead-payment-method" />
</div>
</div>
</div>
</form>
</body>
</html>
You can view this code on jsbin here: http://jsbin.com/iyevux/5/