Call Popup model from Controller response in JAVA

I want to do this : $(this).attr('data-target','#popUpModal');

But I am submitting the form and then based on some logic in controller, I need the Pop-Up model to show.
I don’t want to do it from jquery like above.

Either from controller or from jsp, I need the pop-up to appear once the user submits the form, after all the logic is performed.

You can output a <script> from Java on the server, this isn’t really a question about JavaScript.

Moved to General Web Dev.

Any example you can provide to output a script from java
Thanks in advance.

In your JSP page.

https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/script

I did not get it. The controller loads the jsp that has a pop up in it, But what I want is that the pop up should load directly and not the jsp.

The controller returns like this:
model.addAttribute("something", someForm); return jspThatHasPopUpInIt;

But it loads the jsp. Then I have to do an event to make $('#popUpModal').modal('show');

What I want is that the modal should show automatically from controller.

The JSP is a template for your HTML. The <script> tag to trigger this needs to go in the JSP.
In the JSP this needs to be there somewhere.

<script>$('#popUpModal').modal('show')</script>

I got that. But can you tell me how to achieve the scenario I mentioned in the previous comment?

Are you saying that you want to prevent the form submission from reloading the page?

For that you’ll need to submit the form with AJAX and return JSON from the server rather than HTML.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.