Page 1 of 1

Bug with block__custom_javascripts()

PostPosted: Thu Apr 15, 2010 10:38 am
by kevinwen
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.

Re: Bug with block__custom_javascripts()

PostPosted: Thu Apr 15, 2010 11:04 am
by shannah
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

Re: Bug with block__custom_javascripts()

PostPosted: Thu Apr 15, 2010 2:20 pm
by kevinwen
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?