Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8908407
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:10:16+00:00 2026-06-15T03:10:16+00:00

I am trying to get data from a form in Dart webComponent. The following

  • 0

I am trying to get data from a form in Dart webComponent. The following LoginComponent is defined.
doLogin function is not called when submit button is clicked. Tried placing on-click handler on submit button but that does not work either.

<html><body>
<element name="x-login" constructor="LoginComponent" extends="div">
<template >
    <form id='loginForm' on-submit='doLogin()'>
        <div>
            <h1>Login :</h1>
            <label for="loginName">Login name</label>
            <input type="text" required="required" data-bind="value:loginId" />
            <label>Password</label>
            <input type="password" required="required" data-bind="value:pwd" />
            <input type='submit' value="Login" />
            <input type='button' data-action="click:doCancel" value="Cancel" />               
            <span>{{errorMessage}}</span></div>
        </div>
    </form>      
</template>

<script type="application/dart">
  import 'package:web_components/web_components.dart';      
  import 'ouremr.dart';  
  import 'dart:html';

  class LoginComponent extends WebComponent {
  String errorMessage=""; 
  String loginId='';
  String pwd='';                     
  }                               

    void doLogin(e) {
    print("in do login");
      e.preventDefault();          
      print(loginId);
      print(pwd);

      }  

    void doCancel(e) {
    e.preventDefault();
      errorMessage=' ';         
      style.display='none';
    }                       
  }           
</script>
</element>
</body></html>

doLogin function is not called when form is submitted.
Tried following but that does not work either:

<input type='submit' value="Login" on-click='onLogin()'/> 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:10:17+00:00Added an answer on June 15, 2026 at 3:10 am

    thanks for the question! Really cool to see you playing with Dart’s Web UI libraries.

    I cleaned up your code, and with a few tweaks, it works!

    • Put the handlers like doLogin into the LoginComponent class
    • Had an extra </div> in your template
    • Add $event to your on-click expressions

    See here for the code:

    <!DOCTYPE html>
    
    <html>
      <head>
        <meta charset="utf-8">
        <title>login_page</title>
        <link rel="components" href="login_form.html">
      </head>
      <body>
        <h1>login_page</h1>
    
        <x-login></x-login>
    
        <script type="application/dart">main() {}</script>
        <script type="text/javascript" src="https://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/dart.js"></script>
      </body>
    </html>
    

    and

    <!DOCTYPE html>
    <html><body>
    <element name="x-login" constructor="LoginComponent" extends="div">
    <template >
        <form id='loginForm' on-submit='doLogin($event)'>
            <div>
                <h1>Login :</h1>
                <label for="loginName">Login name</label>
                <input type="text" required="required" data-bind="value:loginId" />
                <label>Password</label>
                <input type="password" required="required" data-bind="value:pwd" />
                <input type='submit' value="Login" />
                <input type='button' on-click="doCancel($event)" value="Cancel" />               
                <span>{{errorMessage}}</span>
            </div>
        </form>      
    </template>
    
    <script type="application/dart">
      import 'package:web_components/web_components.dart'; 
      import 'dart:html';
    
      class LoginComponent extends WebComponent {
       String errorMessage=""; 
       String loginId='';
       String pwd=''; 
    
        void doLogin(Event e) {
          print("in do login");
          e.preventDefault();          
          print(loginId);
          print(pwd);
        }  
    
        void doCancel(Event e) {
          e.preventDefault();
          errorMessage=' ';         
          style.display='none';
        }                       
      }          
    </script>
    </element>
    </body></html>
    

    Hope that helps!

    (note, the above code works with version 0.2.7 of dart_web_components)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get some form data from POST method. Here's the code
I'm trying to get data for my application from a form set in an
i am currently trying to get data from a form in a view to
I'm trying to get data from a POST form. When the user inputs habláis
I have a form that I'm trying to get data from a form using
I'm trying to use jquery to get data from a form and stop the
I am trying to get the data from the form I created where I
I am trying to rewrite an url with GET-data from a form. This works
I am trying to get some data from a Form with jersey and i
So I'm trying to get data from my sql database and sort it by

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.