1

I have a popup window which should close during submit.But it is not closing but data is adding in grid. The script used is

$(document).ready(function(){
    $("#dialog-form").dialog({
        autoOpen : false,
        height : 400,
        width : 700,
        modal : true,
        title: "Currency Details",
        close : function() {
            $(this).dialog("close");
        }
    });

});

And this is my ajaxsubmit

function saveCurrencyAjax() {
        var str = $("#enumCurrency").serialize();
        $.ajax({
            type : "POST",
            url : "../currency/saveEnumCurrency.action",
            data : str,
            success : function(response) {
                $('#dialog-form').dialog('close');

            },
            error : function(e) {
                alert('Error: ' + e);
            }
        });
    };

This is my controller

  @RequestMapping( value="/currency/saveEnumCurrency.action", method=RequestMethod.POST)
        public ModelAndView saveenumCurrency(@ModelAttribute EnumCurrency enumCurrency, Errors errors) throws Exception {   

            ModelAndView mvc = null;
            try{
                List<EnumCurrency> enumCurrencys =  new ArrayList<EnumCurrency>();
                enumCurrencys.add(enumCurrency);
                List<EnumCurrency> enumCurrencysList = enumCurrencyService.create(enumCurrencys);
                mvc =   new ModelAndView("setup/enumCurrencyList");


            } catch (Exception e) {
                e.printStackTrace();
            }
            return mvc; 
        }

Thanks in advance, if need more information inform me.

  • Did you try an alert or console.log in the success callback to ensure it was being run? – m59 Aug 20 '13 at 05:25
  • Ya i tried.Its comming to saveCurrencyAjax(). – Jyoti Dutta Aug 20 '13 at 05:35
  • I don't understand what you mean. Do this: `success : function(response) { alert('success called')` Do you see the alert? – m59 Aug 20 '13 at 05:45
  • yaa it is showing alert message success call. Actually my problem is after submitting data is adding into the grid (after refreshing) but the pop window is not closing. – Jyoti Dutta Aug 20 '13 at 05:54
  • The syntax of the function you are using to close it doesn't make very much sense to me. It seems like it ought to be `dialog.close()` – m59 Aug 20 '13 at 06:14

1 Answers1

0

First Confirm that whether its coming to success Function ! and try this

$('div#popup_content').bind('dialogclose', function(event) {
     alert('closed');
 });

refer - Accepted Answer of this question

Just Try

Community
  • 1
  • 1
Sri
  • 1,505
  • 2
  • 18
  • 35