<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: JQModal fails after jqgrid refreshes</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/jqmodal-fails-after-jqgrid-refreshes</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/jqmodal-fails-after-jqgrid-refreshes/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>neil328 on JQModal fails after jqgrid refreshes</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqmodal-fails-after-jqgrid-refreshes#p25268</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqmodal-fails-after-jqgrid-refreshes#p25268</guid>
        	        	<description><![CDATA[<p>Hi - I am using your grid funciton and launch a modal window for editing data. &#160;This seems to work fine when the grid is intially loaded but if it is refreshed the href class is no longer reconized and instead of a ajax injected form is loaded as a new page which fails becase there is refrences to Jquery. &#160;I am including the scripts below any help would be greatly appreciated. &#160;Thanks in advance.<img class="spSmiley" style="margin:0" class="sfsmiley" title="Laugh" src="/blog/wp-content/forum-smileys/sf-laugh.gif" alt="Laugh" /></p>
<p>I am using MVC 3&#160;</p>
</p>
<p>&#60;script type="text/javascript"&#62;</p>
<p>var headerID = &#60;%=Model.ServiceHeader.TabIndex %&#62;;</p>
</p>
<p>$(document).ready(function () {</p>
<p>grid();</p>
<p>init();</p>
<p>});</p>
</p>
<p>function init()</p>
<p>{</p>
</p>
<p>// handle the event triggered by the modal forms... and update the</p>
<p>// parent window notice the parameter tabid this is so the details page will know the tab</p>
<p>// need to look into why the call back does not close the window correctly...</p>
<p>// i am setting up a call back to use the slide up effect but this does not happen???</p>
<p>$(document).bind("UpdateSuccess",function (event, a) {</p>
<p>$(&#39;#ModalWindow&#39;).jqm({onHide: closeModal});</p>
<p>$(&#39;#ModalWindow&#39;).jqmHide();</p>
<p>$(&#39;#Grid&#39;).trigger("Updated", { tabid:headerID });</p>
<p>});</p>
</p>
<p>// handle event to clear the loading give on the modal window</p>
<p>$(document).bind("WindowLoaded",function() { $("#Loading").hide(); } );</p>
</p>
<p>//-------------------------------------------------</p>
<p>// this section must be defined under the DOM ready funciton</p>
<p>// since it will be used inside and outside of this section</p>
<p>// so we will define a close callback and and open call back</p>
<p>// for the modal window</p>
<p>// the actual trigger function will be called when the grid</p>
<p>// has finished rendoring...</p>
<p>//----------------------------------------------------------------</p>
<p>// define a close call back function for the modal window</p>
<p>var closeModal = function (hash) {</p>
<p>var $modalWindow = $(hash.w);</p>
<p>$modalWindow.slideUp("slow",function () {</p>
<p>if(hash.o) hash.o.remove();</p>
<p>});</p>
<p>} // end close windows</p>
</p>
<p>// define an open call back function for the modal window</p>
<p>var myOpen = function (hash) {</p>
<p>var $modal = $(hash.w);</p>
<p>var $trigger = $(hash.t);</p>
<p>var $modalContainer = $(&#39;iframe&#39;, $modal);</p>
<p>var myUrl = $trigger.attr(&#39;href&#39;);</p>
<p>var myTitle = $trigger.attr(&#39;title&#39;);</p>
<p>$(&#39;#TitleText&#39;).text(myTitle);</p>
</p>
<p>// show simple loading gif while the system gens the screen</p>
<p>// this wil dispaly just below the title line while the while the</p>
<p>// window is opening... it may only blink in some cases</p>
<p>// the modal will trun this off in the document ready function unless i can find</p>
<p>// another event to turn the gif off....</p>
<p>var ajaxLoading = "&#60;img id=&#39;ajax-loader&#39; src=&#39;&#60;%= Url.Content("~/Content/Images") %&#62;/ajax-loader.gif&#39; &#62;";</p>
<p>$("#Loading").html("&#60;p&#62;" + ajaxLoading + " Loading...&#60;/p&#62;");</p>
<p>$("#Loading").show();</p>
</p>
<p>// JNS - This JQuery will intercept a message being returned and check to see</p>
<p>// if it is the correct page - a redirect to login will contain &#60;!DOCTYPE within</p>
<p>// the first 50 characters -</p>
<p>// Check within those first 50 and if it is not there then we are getting the expected page</p>
<p>// Also NOTE - we remove the targe value from the jqm binding and the @href since this</p>
<p>// function handls both items.</p>
<p>$.get(myUrl,null, function(result,e,a) {</p>
<p>$.ajaxSetup({ cache: false });</p>
<p>// check for timeout if so the new page will be the login starting with</p>
<p>// the &#60;!DOCTYPE - else it will be the normal injected page process normally</p>
<p>// get the first 50 chars from the return string and us it to match</p>
<p>if ( a.responseText.slice(0,50 ).indexOf( "&#60;!DOCTYPE") &#62; -1)</p>
<p>{</p>
<p>window.location.href=&#39;&#60;%= Url.Content("~/Account/LogOn") %&#62;&#39;;</p>
<p>}</p>
<p>$(&#39;#Content&#39;).html(result);</p>
<p>});</p>
</p>
<p>$modal.slideDown("slow");</p>
<p>};</p>
<p>//----------------------------------------------------------------------</p>
<p>// end of modal window call back functions</p>
<p>//----------------------------------------------------------------------</p>
</p>
<p>// this function is now bound to the triggering of the grid rendor complete</p>
<p>$("#ModalWindow").bind("Grid_Complete",function() {</p>
<p>$(&#39;#ModalWindow&#39;).jqm({</p>
<p>modal: true,</p>
<p>trigger:&#39;a.Modal&#39;,</p>
<p>onShow: myOpen,</p>
<p>onHide: closeModal</p>
<p>});</p>
</p>
<p>});</p>
<p>} // end of document ready..</p>
</p>
<p>function grid()</p>
<p>{</p>
<p>url = &#39;&#60;%= Url.Content("~/ServiceDef/ServicedefGrid") %&#62;&#39;;</p>
<p>jQuery("#list2").jqGrid({</p>
<p>url:url,</p>
<p>datatype: "json",</p>
<p>jsonReader: {</p>
<p>repeatitems: false,</p>
<p>id: "Id",</p>
<p>root: function(obj) {return obj.rows; },</p>
<p>//page: function(obj){return obj.page},</p>
<p>//total:function(obj){return obj.total},</p>
<p>//records: function(obj){ return obj.records}</p>
<p>},</p>
<p>colNames:[&#39;ID&#39;,&#39;Service Name&#39;, &#39;URL&#39;],</p>
<p>colModel:[</p>
<p>{name:&#39;id&#39;,index:&#39;id&#39;, width:55},</p>
<p>{name:&#39;name&#39;,index:&#39;name&#39;, width:200},</p>
<p>{name:&#39;url&#39;,index:&#39;url&#39;, width:100}</p>
<p>//{name:&#39;amount&#39;,index:&#39;amount&#39;, width:80, align:"right"},</p>
<p>//{name:&#39;tax&#39;,index:&#39;tax&#39;, width:80, align:"right"},</p>
<p>//{name:&#39;total&#39;,index:&#39;total&#39;, width:80,align:"right"},</p>
<p>//{name:&#39;note&#39;,index:&#39;note&#39;, width:150, sortable:false}</p>
<p>],</p>
<p>rowNum:10,</p>
<p>rowList:[10,20,30],</p>
<p>pager: &#39;#pager2&#39;,</p>
<p>sortname: &#39;id&#39;,</p>
<p>viewrecords: true,</p>
<p>sortorder: "desc",</p>
<p>caption:"Service Definition",</p>
<p>gridComplete: function(){ $("#ModalWindow").trigger("Grid_Complete");}</p>
<p>});</p>
<p>jQuery("#list2").jqGrid(&#39;navGrid&#39;,&#39;#pager2&#39;,{edit:false,add:false,del:false});</p>
<p>}</p>
</p>
<p>&#60;/script&#62;</p>
]]></description>
        	        	<pubDate>Wed, 30 Nov 2011 05:53:20 +0200</pubDate>
        </item>
</channel>
</rss>