JavaScript UI Libraries & Blazor Components Suite – Smart UI › Forums › Buttons › OnClick problem in button.
Tagged: button
- This topic has 7 replies, 2 voices, and was last updated 1 week, 4 days ago by Markov.
-
AuthorPosts
-
October 21, 2024 at 12:05 pm #111615tbettinazzi@axioma.itParticipant
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
October 22, 2024 at 8:51 am #111620MarkovKeymasterHi Tullio,
Could you explain in more details what you need to achieve? If it is possible, provide examples, screenshots.
Regards,
MarkovSmart UI Team
https://www.htmlelements.com/October 22, 2024 at 9:17 am #111622tbettinazzi@axioma.itParticipantIn 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
October 23, 2024 at 4:32 pm #111630MarkovKeymasterHi Tullio,
You can use onclick, not onClick.
Regards,
MarkovSmart UI Team
https://www.htmlelements.com/October 25, 2024 at 10:13 am #111650tbettinazzi@axioma.itParticipantI 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
- This reply was modified 2 weeks ago by tbettinazzi@axioma.it.
- This reply was modified 2 weeks ago by tbettinazzi@axioma.it.
October 25, 2024 at 10:43 am #111653MarkovKeymasterHi Tullio,
it will be undefined because the Button does not have such property.
Regards,
MarkovSmart UI Team
https://www.htmlelements.com/October 25, 2024 at 10:53 am #111655tbettinazzi@axioma.itParticipantBut with standard <button> onClick(“alert(this.form);”) works.
I need to launch a javascript passing it the containing form.
Tks
October 28, 2024 at 7:49 am #111658MarkovKeymasterHi 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,
MarkovSmart UI Team
https://www.htmlelements.com/ -
AuthorPosts
- You must be logged in to reply to this topic.