1

There is a problem with this page:

http://www.pubsaregreat.co.uk/culture?category=18&view=pubs

It is not showing images or the Google map, I've debugged it in the Console and it is showing:

ReferenceError: getMainImage is not defined

I have checked through all of the code and the 'getMainImage' is defined within the component (it's a custom component) and it has previously worked - it is also being loading by the browser.

The getMainImage function is as follows:

function getMainImage(venueId, container){
    jQuery('<img id="'+venueId+'_img" src="<?php echo JURI::root().'administrator/components/com_inapub/proxy.php?getphoto=main&venue_id=';?>'+venueId+'" />').load(function(){
            jQuery(container +' :first').replaceWith(this);
        });

Any ideas where I'm going wrong please?

3
  • Are you sure you're using the latest version of the API?
    – Lodder
    Jun 10, 2015 at 7:31
  • Yes, using the correct (and latest) version of the API Jun 10, 2015 at 8:39
  • I've looked through all JS files your importing and inline script, and cannot see the function getMainImage. I only see where you're calling it. Can you add the code you're using to define the function?
    – Lodder
    Jun 10, 2015 at 8:59

1 Answer 1

1

Just some spare of the moment (possible) solutions:

Option 1:

Try wrapping your function in document read:

jQuery(document).ready(function($) {

    function getMainImage(venueId, container) 
    {
        $('<img id="'+venueId+'_img" src="<?php echo JUri::root().'administrator/components/com_inapub/proxy.php?getphoto=main&venue_id=';?>'+venueId+'" />').load(function(){
            $(container +' :first').replaceWith(this);
        });
    }

});

Option 2:

Try making getMainImage a global function:

getMainImage = function(venueId, container) 
{
    jQuery('<img id="'+venueId+'_img" src="<?php echo JUri::root().'administrator/components/com_inapub/proxy.php?getphoto=main&venue_id=';?>'+venueId+'" />').load(function(){
        jQuery(container +' :first').replaceWith(this);
    });
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.