Bug with block__custom_javascripts()

Archived from the Xataface Users forum.

kevinwen — Thu Apr 15, 2010 10:38 am

I declare block__custom_javascripts() in the delegate class to include a javascript file just like the following:

Code: Select all
function block__custom_javascripts(){         echo '<script src="' . DATAFACE_SITE_URL . '/javascript/submithandler.js" type="text/javascript" language="javascript"></script>';     }

This file includes the javascript code that needs to use JQuery framework and looks like the following:

Code: Select all
jQuery(document).ready(function($){     $("input[type='submit']").click(function(){         $(this).attr("disabled","disabled");         $(this).closest("form").submit();     }); });

This javascript file(/javascript/submithandler.js) is available while listing/viewing/editing records. However, the following javascript code is NOT available when listing records:

Code: Select all
<script type="text/javascript" src="/xataface/js/jquery-ui.packed.js"></script>

It then generate the javascirpt error looking like the following:

Can somebody fix this? My version is 1.2.2 1616. Thanks.


shannah — Thu Apr 15, 2010 11:04 am

jQuery is not actually loaded in every page load. It is included in the view and edit tabs I believe, but not all. You should include it in your custom_javascripts block if you want to guarantee its availability.

-Steve


kevinwen — Thu Apr 15, 2010 2:20 pm

If JQuery is included in the custom_javascripts block, then it will be included twice when we touch the view/edit page. How do I use javascript code to make sure JQuery is loaded and loaded only once?