• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1371
  • Last Modified:

Close jqModal window via code

I'm using jqmodal (http://dev.iceburg.net/jquery/jqModal), a plugin for JQuery to create modal windows allowing a user of our CRM system to add notes to our database.

When the user clicks an icon, a modal window opens with the content of that window retrieved via Ajax from another URL.

The content of that window is a form that uses the JQuery ajax feature itself to post data to another URL to store in a database, when the user hits a button.

I want to be able to close the modal window, once the ajax executed within the modal window reports the post has been completed.

I've stripped the code down to the salient parts and is as follows.  Everything works ok on my script, I just need to understand how to close that window, which I'm guessing needs to be where I've placed ###code to close window### in the code.

Any help from users of this great JQuery plugin, will be appreciated.




Default.asp - the main script with the link that triggers the modal window on click
<html>
<head>
<script type="text/javascript" src="javascript/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="javascript/jqModal.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#addnote').jqm({ajax: '@rel', trigger: 'a.addnotetrigger'});
});	
</script>	
</head>
<body class="default">
<div class="jqmWindow" id="addnote">
Please wait... <img src="images/loading.gif" alt="loading" />
</div>	
<a class="addnotetrigger" rel="ajax_addnote.asp?id=123">Add Note</a>
</body>
</html>
 
ajax_addnote.asp - the script that is the content of the modal window pulled via ajax
 
<html>
<head>
<script type="text/javascript" src="javascript/jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
	$("#submitnotebutton").bind("click", function(e){
    	$.post("ajax_createnote.asp", {details: $('#notedetails').val(), associateid: $('#associateid').val()},
		function(data){
			###code to close window###
 
 
		}
	);
});
});	  	
</script>
</head>
<body>
<div class="container">
	<div class="headeradmin">Note</div>
	<table class="standardtable">
	<tr>
	<td>Associate</td>
	<td>
	<input id="associateid" name="associateid">"
	</td>
	</tr>
	<tr>
	<td>Note</td>
	<td>
	<textarea id="notedetails" cols="60" rows="10"></textarea>
	</td>
	</tr>
	<tr>
	<td></td>
	<td>
	<input id="submitnotebutton" type="button" value="Add"
	</td>
	</tr>	
	</table>
</div>
</body>
</html>
 
ajax_createnote.asp
 
This script adds the data from the above form into the database

Open in new window

0
neburton
Asked:
neburton
  • 3
  • 3
1 Solution
 
bugadaCommented:
Try this
$.jqmHide()

Open in new window

0
 
neburtonAuthor Commented:
No - object doesn't support this property or method.
0
 
bugadaCommented:
If "addNote" is the id of your modal dialog try this, otherwise use the proper id.
$('#addnote').jqmHide()

Open in new window

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
neburtonAuthor Commented:
Fixed it.   I didn't need to reload Jquery in ajax_addnote.asp.  When I removed that from the code and called $('#addnote').jqmHide();   it closed the modal dialog as required.
0
 
bugadaCommented:
glad that helped you
0
 
neburtonAuthor Commented:
thanks again!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now