Skip to content

Instantly share code, notes, and snippets.

@mcrider
Created July 7, 2011 00:53
Show Gist options
  • Save mcrider/1068697 to your computer and use it in GitHub Desktop.
Save mcrider/1068697 to your computer and use it in GitHub Desktop.
hack to reload a grid
{**
* urlInDiv.tpl
*
* Copyright (c) 2000-2011 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* Generate JS and HTML to include a URL in a DIV, AJAX-style.
*
*}
<div id="{$inDivDivId}"{if $inDivClass} class="{$inDivClass}"{/if}>{$inDivLoadMessage}</div>
<a href="#" id="reload_{$inDivDivId}">Reload this bad boy</a>
<script type='text/javascript'>
$(function() {ldelim}
function loadDiv() {ldelim}
$.getJSON("{$inDivUrl|escape:"javascript"}", function(jsonData) {ldelim}
if (jsonData.status === true) {ldelim}
$("#{$inDivDivId}").hide().html(jsonData.content).fadeIn(400);
{rdelim} else {ldelim}
// Alert that loading failed
alert(jsonData.content);
{rdelim}
{rdelim});
{rdelim}
$("#reload_{$inDivDivId}").click(function() {ldelim}
loadDiv();
return false;
{rdelim});
loadDiv();
{rdelim});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment