Forum


05:53

30/11/2011

Hi - I am using your grid funciton and launch a modal window for editing data. 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. I am including the scripts below any help would be greatly appreciated. Thanks in advance.
I am using MVC 3
<script type="text/javascript">
var headerID = <%=Model.ServiceHeader.TabIndex %>;
$(document).ready(function () {
grid();
init();
});
function init()
{
// handle the event triggered by the modal forms... and update the
// parent window notice the parameter tabid this is so the details page will know the tab
// need to look into why the call back does not close the window correctly...
// i am setting up a call back to use the slide up effect but this does not happen???
$(document).bind("UpdateSuccess",function (event, a) {
$('#ModalWindow').jqm({onHide: closeModal});
$('#ModalWindow').jqmHide();
$('#Grid').trigger("Updated", { tabid:headerID });
});
// handle event to clear the loading give on the modal window
$(document).bind("WindowLoaded",function() { $("#Loading").hide(); } );
//-------------------------------------------------
// this section must be defined under the DOM ready funciton
// since it will be used inside and outside of this section
// so we will define a close callback and and open call back
// for the modal window
// the actual trigger function will be called when the grid
// has finished rendoring...
//----------------------------------------------------------------
// define a close call back function for the modal window
var closeModal = function (hash) {
var $modalWindow = $(hash.w);
$modalWindow.slideUp("slow",function () {
if(hash.o) hash.o.remove();
});
} // end close windows
// define an open call back function for the modal window
var myOpen = function (hash) {
var $modal = $(hash.w);
var $trigger = $(hash.t);
var $modalContainer = $('iframe', $modal);
var myUrl = $trigger.attr('href');
var myTitle = $trigger.attr('title');
$('#TitleText').text(myTitle);
// show simple loading gif while the system gens the screen
// this wil dispaly just below the title line while the while the
// window is opening... it may only blink in some cases
// the modal will trun this off in the document ready function unless i can find
// another event to turn the gif off....
var ajaxLoading = "<img id='ajax-loader' src='<%= Url.Content("~/Content/Images") %>/ajax-loader.gif' >";
$("#Loading").html("<p>" + ajaxLoading + " Loading...</p>");
$("#Loading").show();
// JNS - This JQuery will intercept a message being returned and check to see
// if it is the correct page - a redirect to login will contain <!DOCTYPE within
// the first 50 characters -
// Check within those first 50 and if it is not there then we are getting the expected page
// Also NOTE - we remove the targe value from the jqm binding and the @href since this
// function handls both items.
$.get(myUrl,null, function(result,e,a) {
$.ajaxSetup({ cache: false });
// check for timeout if so the new page will be the login starting with
// the <!DOCTYPE - else it will be the normal injected page process normally
// get the first 50 chars from the return string and us it to match
if ( a.responseText.slice(0,50 ).indexOf( "<!DOCTYPE") > -1)
{
window.location.href='<%= Url.Content("~/Account/LogOn") %>';
}
$('#Content').html(result);
});
$modal.slideDown("slow");
};
//----------------------------------------------------------------------
// end of modal window call back functions
//----------------------------------------------------------------------
// this function is now bound to the triggering of the grid rendor complete
$("#ModalWindow").bind("Grid_Complete",function() {
$('#ModalWindow').jqm({
modal: true,
trigger:'a.Modal',
onShow: myOpen,
onHide: closeModal
});
});
} // end of document ready..
function grid()
{
url = '<%= Url.Content("~/ServiceDef/ServicedefGrid") %>';
jQuery("#list2").jqGrid({
url:url,
datatype: "json",
jsonReader: {
repeatitems: false,
id: "Id",
root: function(obj) {return obj.rows; },
//page: function(obj){return obj.page},
//total:function(obj){return obj.total},
//records: function(obj){ return obj.records}
},
colNames:['ID','Service Name', 'URL'],
colModel:[
{name:'id',index:'id', width:55},
{name:'name',index:'name', width:200},
{name:'url',index:'url', width:100}
//{name:'amount',index:'amount', width:80, align:"right"},
//{name:'tax',index:'tax', width:80, align:"right"},
//{name:'total',index:'total', width:80,align:"right"},
//{name:'note',index:'note', width:150, sortable:false}
],
rowNum:10,
rowList:[10,20,30],
pager: '#pager2',
sortname: 'id',
viewrecords: true,
sortorder: "desc",
caption:"Service Definition",
gridComplete: function(){ $("#ModalWindow").trigger("Grid_Complete");}
});
jQuery("#list2").jqGrid('navGrid','#pager2',{edit:false,add:false,del:false});
}
</script>
Most Users Ever Online: 715
Currently Online:
46 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66