Onclick does not call function

0

I'm using webpack and babel to use the new features of ES6 , mainly the part of modularization which is working perfectly and I'm also using a development server. It turns out that for some reason in my index.html the onclick event does not call any function that I specify within it:

<button class="btn btn-primary btn-lg mt-5" href="#" role="button" onclick="apostar()">

The error message that appears in the Browser console is this:

  

Uncaught ReferenceError: betting is not defined       at HTMLButtonElement.onclick

I'm using bundle.js usually webpack .

    
asked by anonymous 02.05.2018 / 15:10

2 answers

1

I believe that the apostar function is defined in a *.js separate file, as well as sends the good practices.

but it must be minified by webpack , and during this process variables (including functions) are renamed.

What I advise is that you also apply good practices in your HTML file and do not bind inline functions, instead use good old addEventListener .

    
02.05.2018 / 15:39
0

Good morning, as Lucas said, it may be that your call is not working, put it at the bottom of the page.

@section scripts {

@Scripts.Render("~/JS/Funcao")

}

    
02.05.2018 / 15:44