Tagged: 

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #111615

    I’m tryng to substitute html button with <smart-button>.

    In my button, which is within a <form> tag, I do, in the onClick, testLogin(this.form), there testLogin is a very simple jsvascript.

    function testLogin(f) {
    console.log(“testLogin :”+f.username.value+” / “)
    urlResponse = “server/licenseTester?username=”+f.username.value;
    console.log(“testLogin2 :”+urlResponse)
    sendLoginTest(urlResponse);
    return true;
    };

    It works fine with html button.

    Doing it with smart-button the variable f in the js is undefined.

    What’s wrong ?

    Is there an alternative syntax ?

    Tks

    #111620
    Markov
    Keymaster

    Hi Tullio,

    Could you explain in more details what you need to achieve? If it is possible, provide examples, screenshots.

    Regards,
    Markov

    Smart UI Team
    https://www.htmlelements.com/

    #111622

    In my code I’ve

    <button onClick=”testLogin(this.form) class=…>

    where testLogin is a very simple js shown above.

    When I substitute with

    <smart-button onClick=”testLogin(this.form) class=…> seems that this.form is undefined and then the testLogin js fails telling me the variable is should receive is undefined.

    Why this.form is undefined with smart-button ?

    What’s the alternative ?

    Tks

     

    #111630
    Markov
    Keymaster

    Hi Tullio,

    You can use onclick, not onClick.

    Regards,
    Markov

    Smart UI Team
    https://www.htmlelements.com/

    #111650

    I tried but this doesn’t solve my problem.

    I tried with
    <script>

    const button = document.querySelector(“#button#);

    button.addEventListener(‘click’,  function(event) {

    alert(‘Ci sono ‘ + button.form);

    });

    </script
    but button.form is undefined.

    Tried also with this.form, same result.

    How can I solve.

    Tks

     

    #111653
    Markov
    Keymaster

    Hi Tullio,

    it will be undefined because the Button does not have such property.

    Regards,
    Markov

    Smart UI Team
    https://www.htmlelements.com/

    #111655

    But with standard <button> onClick(“alert(this.form);”) works.

    I need to launch a javascript passing it the containing form.

    Tks

    #111658
    Markov
    Keymaster

    Hi Tullio,

    The list of supported properties by the button is available in the Button’s API Docs. We do not have a property called “form” so this will be undefined in this case. I will create a work item for adding this, but at present we do not have it.

    Best Regards,
    Markov

    Smart UI Team
    https://www.htmlelements.com/

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.