confirm form submit with jquery UI
<p>I'm trying to confirm a submit form that is created using ruby on rails, but before submitting I have a condition that open a confirm popup asking if the user really wants to do it. This is working with the default confirm browser box. But now i'm trying to do it with Jquery UI but it's not working. How can I return true or false using jquery ui ?</p>

<p>If the user click "yes" the form should be submitted, if "no" it should just close</p>

<p>this is my jquery ui function:</p>

<pre><code>  function confirm(message, callback) {
    $('body').append('&lt;div id="confirm" style="display:none"&gt;'+message+'&lt;/div&gt;');
    $( "#confirm" ).dialog({
      resizable: false,
      title: 'Confirm',
      zIndex: 99999999,
      modal: true,
      buttons: [
        {
          text: "Yes",
          click: function() {
            $(this).dialog("close");
            if ($.isFunction(callback)) {
              callback.apply();
            }

          }
        },{
          text: "No",
          click: function() { $(this).dialog("close");}
        }
      ],
      close: function(event, ui) {
        $('#confirm').remove();
      }
    });
  }
</code></pre>

<p>And my submit function:</p>

<pre><code>     $('form').submit(function(){

          &lt;% @meetings.each do |mt| %&gt;

       ...

          &lt;%# cvalue_starthour.value %&gt;

          $meeting_dates = [];

     ...

          $.each($meeting_dates, function (index, value) {
            $.each($test, function (index2, value2) {
);

              if (value.priority == "&lt;%= l(:default_priority_trivial) %&gt;" || "&lt;%= l(:default_priority_minor) %&gt;" || "&lt;%= l(:default_priority_major) %&gt;") {

                if ((value.date == value2.date) &amp;&amp; (value.time == value2.time)) {
                  message = confirm("Are you sure?");


                }
              }
            });
          });


          &lt;%      end %&gt;


          &lt;%  end %&gt;

          if (message) {
            return true;
          } else {
            return false;
          }
        });


      });
</code></pre>