0

http://35.178.2.150/rep/india please hit this URL and inspect it, and help me if you can.

closed as off-topic by Mohit Kumar Arora, Manashvi Birla, Amit Bera Mar 4 at 13:01

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions on problems in code you've written must describe the specific problem and include valid code to reproduce it. For help writing short, self-contained syntactically-valid examples, see: http://sscce.org/" – Mohit Kumar Arora, Manashvi Birla, Amit Bera
If this question can be reworded to fit the rules in the help center, please edit the question.

  • why not redeploy your static view files and check if those errors you are talking still exists. By the way, posting links instead of describing your specific issue or problem seems to be so lazy – fmsthird Mar 4 at 11:40
  • done with it, but still the same error – Farhan Ali Mar 4 at 11:41
  • Are you implementing any external js – Prathap Gunasekaran Mar 4 at 11:41
  • you should run setup upgrade before redeploying static contents – fmsthird Mar 4 at 11:41
  • This is nothing related to deploying again or upgrade issue – Prathap Gunasekaran Mar 4 at 11:42
1

Your file path for your js should be here Vendor_Modulename/web/js/myfile.js

var config = {
    paths: {            
         'myfile': "Vendor_Modulename/js/myfile"
      },   
    shim: {
    'myfile': {
        deps: ['jquery']
    }
  }
} 

After that you can load the js inside your views like

<srcipt>
 require(["jquery","myfile"],function($,myfile){
     $(document).ready(function(){
        //call your js here...
     })
 })
</script>

If still your js is not working you can add setTimeOut js built in function which can load js after few couple of seconds of your body loading.

setTimeout(function(){ alert("Hello"); }, 3000);

Actually the best solution for you is to load your js after your body loading. You can also use (document).ready or (window).load as well.

1

Add an external JS in the following way :

Try this,

Add your custom js in the following path.

Vendor/Module/view/frontend/web/js/nameofjs.js

then you need to add requirejs-config.js to the following path.

Vendor/Module/view/frontend/requirejs-config.js

then add the following code in it

 var config = {
    paths: {            
            'your_js_name' : 'js/nameofjs', // loadcustomjs is an name and it can anything in lowercase
        },                                                                
    shim: {
    'your_js_name': {
        deps: ['jquery']
    },
  }
};

and in the phtml which loads in a page or wherever you want to load this js, add the below code in it.

require(['jquery','your_js_name'],function($) {
$(window).load(function () {
     /*alert('load from external jquery');*/
});});

Hope this helps and this is correct way to load any custom js in M2 as far as I know.

Peace :)

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