Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

0

No meed all that js files! this has worked for me as treat give a try using settings: <field name="open_amount"> <argument name="data" xsi:type="array"> ....<!-- More Configuration--> </argument> <settings> <switcherConfig> <rules> <rule name="0"> ...


1

document.getElementById("code_a_barre") is null That would suggest there isn't an element on the page which has id="code_a_barre" As you are using jQuery you could use $('#code_a_barre') But also remember that magento 2 uses require-js. So you need something like this: require(['jquery'], function($){ $(document).ready(function () { var ...


0

I advise downloading the JS file from the Owl carousel website and including it in your theme. Steps for that can be found here as Prathap linked. But if you really want to include external JS you can do so via layout XML: <?xml version="1.0" ?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:...


0

You can use appendChild() for the head element rather than document.write() script = d.createElement('script'); script.type = 'text/javascript'; script.async = true; script.onload = function(){ // remote script has loaded }; script.src = 'https://your-script-here.com/script.js'; d.getElementsByTagName('head')[0].appendChild(script); Note I wouldn't ...


2

I did R & D on this task and prepared some implementation notes it might help you others if you would like to do, please follow the below steps on Advanced JS Bundling. A) Required Tools node.js >= 8.x npm >= 6.x Magento 2 DevTool Git B) DevTool Installation Clone the repository in your local machine Ex: git clone https://github.com/magento/m2-...


2

You can use jQuery events like below method will work <script> require(['jquery', 'jquery/ui'],function($){ jQuery('#nbrbox').on('input', function(){ var nbrbox = document.getElementById('nbrbox').value; var qtybox = parseFloat(document.getElementById('qtybox').textContent); var qtysquare =(Math.round(nbrbox*...


1

The best practice is to use mixins. I also note that requirejs-config.js is wrong. We don't need web folder in the path. Magento_Ui/web/js/modal/modal => Magento_Ui/js/modal/modal Using mixins: app/code/Vendor/Module/view/frontend/requirejs-config.js var config = { config: { mixins: { 'Magento_Ui/js/modal/modal': { ...


0

There is a easier version using deps. Dependencies in the requirejs-config.js will load your file when loading requirejs itself (everywhere in the shop). Here is an example of how your requirejs-config.js should look: var config = { // When load 'requirejs' always load the following files also deps: [ 'common-js' ], // Library file ...


0

Please follow these steps. Change to your Magento Directory find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + sudo chown -R <Magento User>:<web server group> . chmod u+x bin/magento Once permission is set deploy your files as ...


0

Please try by giving 777 permission to generated and var folder Try after Removing generated folder and var/cahe var/di and var/page_cache and var/view_processed and try it . Will be better if you try on local first instead of directly on live.


0

If your Magento store is in production mode then Magento ≥ 2.2 It can be done by the command line php bin/magento config:set dev/js/enable_js_bundling 1 php bin/magento cache:clean Magento < 2.2 UPDATE `core_config_data` SET `value`='1' WHERE `path`='dev/js/enable_js_bundling'; Then run this command php bin/magento cache:clean


0

How to enable bundling in Magento: If your Magento store is in developer mode then go to Store->configuration->advanced->Develoer->JavaScript Settings and set Enable JavaScript Bundling to yes and then deploy your Magento store in production mode by following the command php bin/magento deploy:mode:set production and clear cache then ...


0

Try this Just Open the MAGENTO_ROOT/app/etc/di.xml and replace below code form line number 574 <item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item> TO <item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Copy</...


0

Does your Magento 2.3 /pub/static/.htaccess file match the contents at Magento 2.3's GitHub Repo? Are you in Developer or Production mode? php bin/magento deploy:mode:show Does this issue exist in developer mode? php bin/magento deploy:mode:set developer If this issue exists only in production mode, then try: rm -rf pub/static/* php bin/magento cache:...


0

Deploy your static content and clear your cache php bin/magento setup:static-content:deploy php bin/magento cache:flush If that doesn't resolve it, look at the permissions for the files.


0

This is right way $('#btn').click(function() { $("#element").accordion("activate", [1]); });


0

Reference Link :- Try This :- $fieldset->addField( 'filename', 'file', [ 'label' => __('File'), 'title' => __('File'), 'name' => 'filename', 'required' => true, 'disabled' => $isElementDisabled ] );


0

You can put the validation into your controller, which save the value of this field like this. public function __construct( ... \Magento\Framework\File\UploaderFactory $uploaderFactory, ... ) { ...... $this->uploaderFactory = $uploaderFactory; ..... } public function execute() { try { $destinationFolder = 'PATH OF ...


2

You can do this by adding a layout handles (say your_layout.xml) using event observer ( for event layout_load_before) and then on the your_layout.xml you can add JS and CSS file. Steps are given below. I assume you are using a module names "Company_MyModule". step 1) create file events.xml under YOUR-MAGENTO-ROOT/app/code/Company/MyModule/etc/frontend ...


1

Replace your form code with below <field name="open_amount" formElement="checkbox"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="component" xsi:type="string">[Vendor]_[Module]/js/mycheckbox</item> <item name="source" xsi:...


1

For the toggle field, single-checkbox.js file is responsible for this. so you need to extend the single-checkbox.js file in your custom module. First, create a require-config.js file in below path. app/code/Namespace/Modulename/view/adminhtml/requirejs-config.js var config = { 'paths': { 'fabric': 'Magedelight_Productlabel/js/fabric' }, map: { ...


1

This problem appears when we set the backend setting for Use Custom Admin URL wrong. To get rid of this problem, follow the steps mentioned below: Login to the database and open the core_config_data table. Find and remove the row having the path like admin/url/custom. Now find the value where scope = stores scope_id = 0 path = web/secure/...


1

<script type="text/javascript"> require([ 'jquery', 'jquery/ui'], function($){ $(document).on("click","#acceptnow", function(e) { var currentRow=$(this).closest("tr"); var col1=currentRow.find(".quoteid").text().toString().trim(); var col2=currentRow.find("td:eq(3)").text().toString().trim(); var col3=...


0

Yes, you can remove unnecessary Magento modules via composer.json https://www.integer-net.com/removing-unused-core-modules-from-magento-2-the-right-way/


0

You may not use js mixin for the particular js file you try to override (i.e /vendor/magento/module-sales/view/adminhtml/web/order/create/scripts.js). Also, your require-config.js declaration is wrong but this not matter since mixin will not work for the js file /vendor/magento/module-sales/view/adminhtml/web/order/create/scripts.js You may try below steps ...


0

Avishek, if you want to let any shopper outside of your domestic country know they are responsible for duties and taxes, there is an app on the Magento App store, Zonos Hello. It will also estimate the duty and tax amount on the item pages. It is a free app. (You can also configure it to run in your checkout)


0

Thanks ManiMaran!! This is indeed the secret for getting more complex javascript to work inside Magento 2. <script> require(['jquery'],function($) { //YOUR LOVELY JAVASCRIPT GOES HERE AND WILL NOW WORK IN CMS PAGE }); </script>


0

Try this, <script> require(['jquery','FlipBook'], function($){ $('#side').FlipBook({ pdf: 'sample.pdf', }); }); </script> For more about the implementation custom javascript implementation Hope this helps.


1

Rename module name module-ui to Magento_Ui


1

Try this, You must rename your module-ui to Magento_Ui Copy the file from below path vendor/magento/module-ui/view/base/web/js/form/element/post-code.js to app/design/frontend/{Vendor}/{theme-name}/Magento_Ui/web/js/form/element/post-code.js then run the below commands. php bin/magento setup:upgrade php bin/magento setup:static-content:deploy -f ...


0

Magento never adds this type of string in java script tag. There might be some malicious code. You need to debug and check, from where it's being happened. Have you implemented SUPEE-11086 patch? if not then don't wait and just implement it. https://magento.com/security/patches/supee-11086


Top 50 recent answers are included