News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Inline Javascript problem with template overriding on user fields editing

Started by andresf, January 06, 2015, 18:16:05 PM

Previous topic - Next topic

andresf

Hello, everyone.

First, a background for the issue:

- I'm overriding the views via template /templates/template/html/com_virtuemart On Virtuemart 3.0.2 - Joomla! 3.3.6
- For perfomance purposes, we have a Joomla! plugin that moves all the external and inline Javascript to the bottom of the page


The problem:

I'm current overriding the user fields edit view, which so far includes the scripts: /user/edit_address.php and /user/edit_address_userfields.php. These views include inline scripts which break the page, (because JS libraries aren't loaded yet). The scripts which break the page are:


<script id="vm.countryState_js" defer type="text/javascript"> //<![CDATA[
jQuery( function($) {
$("#virtuemart_country_id").vm2front("list",{dest : "#virtuemart_state_id",ids : "",prefiks : ""});
});
//]]></script>



<script id="datepicker_js" defer type="text/javascript"> //<![CDATA[
jQuery(document).ready( function($) {
$(".datepicker").live( "focus", function() {
$( this ).datepicker({
changeMonth: true,
changeYear: true,
yearRange: "1915:2015",
dateFormat:"y.mm.dd",
altField: $(this).prev(),
altFormat: "yy-mm-dd"
});
});
$(".js-date-reset").click(function() {
$(this).prev("input").val("-Nunca-").prev("input").val("0");
});
});
//]] </script>



<script id="vm.countryStateshipto__js" defer type="text/javascript"> //<![CDATA[
jQuery( function($) {
$("#shipto_virtuemart_country_id").vm2front("list",{dest : "#shipto_virtuemart_state_id",ids : "",prefiks : "shipto_"});
});
//]]> </script>


What I want to know is where and how are these scripts injected so I can override them, because I've been looking for several hours and haven't found them.

I've already overrided in this specific view the inline JS generated by the function vmValidator() from the file edit/view.html.php by recreating that function within the overriding script and replacing the line

$this->vmValidator(); for JFactory::getDocument()->addScriptDeclaration(vmValidatorOverride());

And I intend to keep like this for every other inline script of the views I have to override.

Thanks in advance for any help with this issue.

GJC Web Design

GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

andresf

Thanks, for your reply.

It doesn't help that much. Actually that's the class that causes the error. Looks like it doesn't employs the JDocument class, because it outputs the JS script inline.