1

I am trying to integrate Spring MVC + jquery + modal in a application where the modal is an iframe.

The jquery plugin is SimpleModal.

The screen is pretty simple. The landing page is a production page which has 2 products in which the prices are based on a zip code.

When the page load it runs the following:

$(window).load(function(){
    var param = $.url().param('zipcode');
    alert("zipcode = " + param);
    if(null == param || param.length == 0)
    {
      $.modal('<iframe src="zip-code.html" height="240" width="380" scrolling="no">', {
        //overlayClose:false,
        //closeHTML:""
        //onClose: contact.close
        });
    }

  });

The zip code box is displayed and the user simple enters in the zip code and selects Applied.

The zip code has to be checked to see if it is valid and belongs to a given region. If errors, then the zip code box is displayed, otherwise the zip code is accepted and the window is suppose to close and the landing page is to be refreshed with the prices.

Now I created a simple controller for both the landing page and the zip code modal window. The zip code modal makes use of the same controller as the landing page.

What is happening is that when the user selects the apply button and the zip code is valid, instead of the modal window closing, it is getting redirected to the landing page url.

I am new to jQuery. I have search the web to see if others are using spring mvc with modals or popup windows and I have been unsuccessful in that search.

1
  • How are you submitting the page(apply button)? Are you doing a html form submission? If you are doing so, you have to change it using the jquery ajax(api.jquery.com/jQuery.ajax). May 2, 2011 at 6:36

1 Answer 1

0

You should put this on your landing page:

<script>
    ...
    function closeModal(){
      //code to close your modal
    }
</script>

The following script should be on you "success page" (the one which loads when zip code is OK)

<script>
    window.parent.closeModal();
</script>

The last script calls the closeModal public function in your landing page, so it closes the modal.

Hope this helps. Cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.