Welcome Guest, Not a member yet? Register   Sign In
jquery modal passing post values to controller
#4

[eluser]gdawson[/eluser]
I was able to get this to work. Below is the resulting code.

JS
Code:
$(function() {
  // a workaround for a flaw in the demo system (http://dev.jqueryui.com/ticket/4375), ignore!
  $( "#dialog:ui-dialog" ).dialog( "destroy" );
  
  var note = $( "#note" ), allFields = $( [] ).add( note );
  $( "#dialog-form" ).dialog({
   autoOpen: false,
   height: 450,
   width: 450,
   modal: true,
   buttons: {
    "Add Note": function() {
     var bValid = true;
     allFields.removeClass( "ui-state-error" );
                                        
     if ( bValid ) {
                                                note.val()
                                                document.noteform.submit();            
      $( this ).dialog( "close" );
     }
    },
    Cancel: function() {
     $( this ).dialog( "close" );
    }
   },
   close: function() {
    allFields.val( "" ).removeClass( "ui-state-error" );
   }
  });

  $( "#create-note" )
   .button()
   .click(function() {
    $( "#dialog-form" ).dialog( "open" );
   });
});
[removed]

HTML
Code:
<button id="create-note">Add Note</button>

<div id="dialog-form" title="Add Note">


     &lt;form action="&lt;?= base_url();?&gt;notes/addNote/" method="post" name="noteform" id="noteform"&gt;
<fieldset>
  <label for="note"></label>
                &lt;textarea type="text" cols="25" rows="10" name="note" id="note" class="text ui-widget-content ui-corner-all" &gt;&lt;/textarea>
</fieldset>
&lt;/form&gt;
</div>

Controller
Code:
newNote = $this->input->post('note');


Messages In This Thread
jquery modal passing post values to controller - by El Forum - 07-30-2012, 05:44 PM
jquery modal passing post values to controller - by El Forum - 07-30-2012, 07:01 PM
jquery modal passing post values to controller - by El Forum - 07-31-2012, 02:59 PM
jquery modal passing post values to controller - by El Forum - 07-31-2012, 04:52 PM



Theme © iAndrew 2016 - Forum software by © MyBB