Solved

jquery dialog with jsp include

Posted on 2013-01-28
2
3,952 Views
Last Modified: 2013-02-04
Dear Experts,


This is my Main JSP.

<form name="mainPage" method="POST" target="action.do">
   <jsp:include page="subPage.jsp" ></jsp:include>
   <input type="button" onclick="openDialog()" value="Open Dialog"/>
    ...
    <input type="submit" value="SubmitPage" />
</form>
<script type="text/javascript">
  function openDialog(){
      $('#dialog').dialog("open");
  }
</script>

Open in new window


This is subPage.jsp
<div id="dialog">
  <table>
    .....
  </table>
</div>
<script type="text/javascript">
  $('#dialog').dialog({autoOpen: false});
</script>

Open in new window


During first load, all are working good. The table in 'dialog' div will be hidden till the button click in main jsp.
On submitting the form, when the page get reloads then the dialog table is appears in the page and the 'Open dialog' is not opening the popup. Is this problem due to using <jsp:include> ? Also, Please let me any alternative solutions for this.
0
Comment
Question by:Gangadhara Melukote
2 Comments
 
LVL 22

Accepted Solution

by:
Mrunal earned 500 total points
ID: 38830652
hi
For the  <table> tag inside <div id="dialog"> , add css property for display none. like this:

<table id="tbl1" style="display: none;"> ... </table>

and instead of directly adding -

<script type="text/javascript">
  $('#dialog').dialog({autoOpen: false});
</script>

do it like this:

1. Add id for dialog button:

<input id="btnDialog" type="button" onclick="openDialog()" value="Open Dialog"/>

2. $(document).ready(function(){
  $('#btnDialog').click(function(){
    $('#dialog').dialog({autoOpen: false});
  });
});

Hope this helps you.
0
 

Author Comment

by:Gangadhara Melukote
ID: 38851522
Thanks. This worked good!!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
going to wrong jsp page 2 34
Javascript Form Change 5 31
Making an "H1" a specific color only on a specific page. 3 27
JavaScript Loan Calculator Error 3 17
I have answered several questions lately that were solved utilizing the power of jQuery's AJAX functions, so I thought I would write an article demonstrating the ease of use. Why should I use jQuery as opposed to regular JavaScript? Now I know…
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question