VirtueMart Forum

VirtueMart 2 + 3 + 4 => Frontend Modules => Topic started by: jorgepracticum on October 14, 2015, 18:02:59 PM

Title: $("#'.$prefix.'virtuemart_country_id").vm2front is not a function
Post by: jorgepracticum on October 14, 2015, 18:02:59 PM
Hi
I'm trying to display my shop in my frontend. But when i check the console i see this message:
Quote$("#'.$prefix.'virtuemart_country_id").vm2front
With this error my page doesn't load all the javascript code so i had to comment one line in this file:
Quoteadministrator/components/com_virtuemart/helpers/vmjsapi.php
and the line to comment was:
jQuery( function($) {
                               //The next line i had to comment
                       //$("#'.$prefix.'virtuemart_country_id").vm2front("list",{dest : "#'.$prefix.'virtuemart_state_id",ids : "'.$stateIds.'",prefiks : "'.$prefix.'"});
     });

This is not a real solution, so can anyone help me?
I'm using Joomla 3.4.4 and VM 3
Regards
Title: Re: $("#'.$prefix.'virtuemart_country_id").vm2front is not a function
Post by: Studio 42 on October 14, 2015, 22:04:42 PM
This is a quote problem here. Or you need to escape or change quotes.
the code should something so to give the right result :
$js = 'jQuery( function($) {
       $("#'.$prefix.'virtuemart_country_id").vm2front("list",{dest : "#'.$prefix.'virtuemart_state_id",ids : "'.$stateIds.'",prefiks : "'.$prefix.'"});
});';

But i have not the full code to check your quote problem now. This can be in some VM release only.
Title: Re: $("#'.$prefix.'virtuemart_country_id").vm2front is not a function
Post by: jorgepracticum on October 15, 2015, 20:15:19 PM
Hi
This is more code lines:
VmJsApi::jSite();
                self::addJScript('vm.countryState'.$prefix,'
//<![CDATA[
                jQuery( function($) {
                        //$("#'.$prefix.'virtuemart_country_id").vm2front("list",{dest : "#'.$prefix.'virtuemart_state_id",ids : "'.$stateIds.'",prefiks : "'.$prefix.'"});
                });
//]]>
                ');
Title: Re: $("#'.$prefix.'virtuemart_country_id").vm2front is not a function
Post by: Studio 42 on October 15, 2015, 22:02:12 PM
The full code is :
static function JcountryStateList($stateIds, $prefix='') {
static $JcountryStateList = array();
if (isset($JcountryStateList[$prefix]) or !VmConfig::get ('jsite', TRUE)) {
return;
}
VmJsApi::jSite();
self::addJScript('vm.countryState'.$prefix,'
//<![CDATA[
jQuery( function($) {
$("#'.$prefix.'virtuemart_country_id").vm2front("list",{dest : "#'.$prefix.'virtuemart_state_id",ids : "'.$stateIds.'",prefiks : "'.$prefix.'"});
});
//]]>
');
$JcountryStateList[$prefix] = TRUE;
return;
}

And is full valid.
Or you have a server setting/problem, or a bad VM release.
Try to update virtuemart or check with your provider.
You can remove CDATA if you use html4 or html5 , because this is only to be xhtml valid, perhaps this help.
But in all case the problem is not the code here.

Regards,
Patrick
Title: Re: $("#'.$prefix.'virtuemart_country_id").vm2front is not a function
Post by: jorgepracticum on October 15, 2015, 22:32:56 PM
I've removed CDATA but I still have the same problem
I think that the component or my web doesn't charge all the libraries
The real problem is the function vm2front, the web doesn't recognize it
Title: Re: $("#'.$prefix.'virtuemart_country_id").vm2front is not a function
Post by: Studio 42 on October 15, 2015, 23:00:00 PM
CHeck your VM config in "template" tab.
if Using the Script ajax Countries / Regions is checked.
And perhaps the problem can come from your template. Try default protostar template.
If this not work, Send a link to your site, then someone can verify if some javascript files are not loaded.
Title: Re: $("#'.$prefix.'virtuemart_country_id").vm2front is not a function
Post by: jorgepracticum on October 16, 2015, 11:33:51 AM
Hi
I'm using the script ajax Countries / Regions
If is not checked that option, the website load properly
So if this is not necessary I think I'll disactivate
For verify if some javascript files are not loaded, do you need administration permissions?
Title: Re: $("#'.$prefix.'virtuemart_country_id").vm2front is not a function
Post by: GJC Web Design on October 16, 2015, 12:42:52 PM
just compare your source or in Firebug to the demo site..
Title: Re: $("#'.$prefix.'virtuemart_country_id").vm2front is not a function
Post by: Studio 42 on October 16, 2015, 16:44:55 PM
You need this script to get region for countries
Quote from: jorgepracticum on October 16, 2015, 11:33:51 AM
Hi
I'm using the script ajax Countries / Regions
If is not checked that option, the website load properly
So if this is not necessary I think I'll disactivate
For verify if some javascript files are not loaded, do you need administration permissions?