Solved

jquery dialog with jsp include

Posted on 2013-01-28
2
3,831 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
Comment Utility
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
Comment Utility
Thanks. This worked good!!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

DOM Attributes and Properties treatment with jQuery 1.6 by Ivo Stoykov jQuery (http://jquery.com/) 1.6 introduces .prop() (http://api.jquery.com/prop/) and .removeProp() (http://api.jquery.com/removeProp/) methods which allow modifying or removi…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now