Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok, I got it working.</p> <p>Shuffled some of the code around, moving function in-line etc. But it wasnt helping. The success call was being made, I was getting the id back in the call, but no row creation, and wasnt closing the dialog. Modified the selector on the dialog close and got that working. So I was thinking it was probably the selector on the table addition that was the problem.</p> <p>I pulled the html out of the tr.after() call and put it in a variable so I could put it out in an alert just prior to the after() call so that I could guarantee that I was passing in valid HTML ... For some reason this fixed the problem.</p> <p>Here is the working version.</p> <pre><code>$j("#dialog-form").dialog( { autoOpen : false, height : 500, width : 500, modal : true, buttons : { "Add Shipping Point" : function() { var bValid = true; var cityValid = true; var stateValid = true; var zipPresent = true; var zipValid = true; updateTips(""); allFields.removeClass("ui-state-error"); cityValid = checkRequired(city, "City"); stateValid = checkRequired(state, "State"); zipPresent = checkRequired(zip, "Zip"); if(zipPresent) { zipValid = checkRegexp(zip, /(^\d{5}$)|(^\d{5}-\d{4}$)/, "Zip Code"); } bValid = cityValid &amp;&amp; stateValid &amp;&amp; zipPresent &amp;&amp; zipValid; if (bValid) { //alert("Before save shipping point."); function saveShippingPoint() { //alert("Before ajax call."); $j.ajax( { url: "&lt;portlet:resourceURL id='saveShippingPoint'/&gt;" + "?city=" + $j( "#city" ).val().toUpperCase() + "&amp;state=" + $j( "#state" ).val().toUpperCase() + "&amp;stateOther=" + $j( "#stateOther" ).val().toUpperCase() + "&amp;zip=" + $j( "#zip" ).val() + "&amp;product=" + $j( "#product" ).val().toUpperCase() , type: 'GET', cache: false, timeout: 30000, success: function(data) { var row = "&lt;tr&gt;" + "&lt;td&gt;" + city.val().toUpperCase() + ", " + state.val().toUpperCase() + "&lt;/td&gt;" + "&lt;td&gt;" + "&lt;INPUT type='checkbox' NAME='chk' VALUE='"+ data + "' /&gt;" + "&lt;INPUT type='hidden' NAME='shipPointId' VALUE='"+ data + "' /&gt;" + "&lt;/td&gt;" + "&lt;/tr&gt;"; //alert("In success callback. About to add row " + row); //$j("#shipPoints').find('tbody tr:last").after( $j("#shipPoints tr:last").after(row); //alert("After ajax call. About to call close"); $j("#dialog-form").dialog("close"); }, error: function() { alert("There was a problem adding the shipping point."); } }); }; saveShippingPoint(); } }, Cancel : function() { $j(this).dialog("close"); } }, close : function() { allFields.val("").removeClass("ui-state-error"); } }); </code></pre> <p>Thanks to all for your help. If anyone knows why introducing the row variable fixed the after call let me know.</p> <p>-Jim</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload