Why wont this Code execute?
<p><strong>This Run like it is perfectly fine.</strong></p>

<pre><code>// Save, set state to finalized and Print
        $('#btnDialogPrint').click(function () {

            if ($('#chkFinal').is(':checked')) {
                $(function () {
                    $("#PrintDialog").dialog('close');    
                });
            }
            else {
                $('#chkFinal').attr('checked', true); // Set finalized. This checkbox is not visible its like a hidden field
                $('#btnSubmit').click(); // Save
            }

        });
</code></pre>

<p><strong>And this also runs fine:</strong></p>

<pre><code>window.location = '../Print/' + $('#SalesContractId').val();
</code></pre>

<p><strong>But when i put them together it only run's the</strong> </p>

<blockquote>
  <p><strong>window.location = '../Print/' + $('#SalesContractId').val();</strong></p>
</blockquote>

<p><strong>Complete Code:</strong></p>

<pre><code>// Save, set state to finalized and Print
    $('#btnDialogPrint').click(function () {

        if ($('#chkFinal').is(':checked')) {

            $(function () {
                $("#PrintDialog").dialog('close');
                window.location = '../Print/' + $('#SalesContractId').val();    // Moves to ContractController Print
            });
        }
        else {
            $('#chkFinal').attr('checked', true); // Set finalized. This checkbox is not visible its like a hidden field
            $('#btnSubmit').click(); // Save
             window.location = '../Print/' + $('#SalesContractId').val();    // does not alow above code to execute 
        }

    });
</code></pre>
