0

I'm a little new to Polymer and don't quite get what's happening here. I'm trying to create a simple form page. This is the code:

<dom-module id="sams-add-student">
  <template >
    <div class="vertical-section">
      <paper-button on-click="addstudent">SUBMIT</paper-button>
    </div>
  </template>

  <script>
    (function() {
      'use strict';

      Polymer({
        is: 'sams-add-student',

        properties: {
          item: {
            type: Object
          },
          addstudent: function (event) {
            console.log('addstudent');
          }
        }

      });
    })();
  </script>

</dom-module>

However, I get an error that the listener method is not defined. Am I missing something?

Dry House
  • 11
  • 1
  • 3

2 Answers2

1

You've incorrectly declared the addstudent method inside properties when it should actually be outside properties at the top-level of the object.

Polymer({
  is: 'sams-add-student',

  properties: {
  //  addstudent: function() {...} // DON'T DO THIS HERE
  },

  addstudent: function() {...} // DO THIS HERE
}

codepen

tony19
  • 125,647
  • 18
  • 229
  • 307
1

If it is a paper input, you could use something like :

this.$.IDofyourelement.value;
Martin Evans
  • 45,791
  • 17
  • 81
  • 97
akshay bhoendie
  • 273
  • 3
  • 10