Binding a form's action attribute

44 views
Skip to first unread message

Julien Silland

unread,
Jun 29, 2015, 5:52:46 PM6/29/15
to polymer-dev
Is this something that should work? I can't seem to get it to work — here's a simplified version of my element:

In my document:
<my-custom-element form-action="#{populate_orders_path}"></my-custom-element>

(The populate_orders_path is defined by my Rails server and returns "/store/orders/populate")

Element definition:
<dom-module id="my-custom-element">
  <template>
    <form action="{{formAction}}">
      …
    </form>
  </template>
  <script src="MyCustomElement.js"></script>
</dom-module>

JS (Coffeescript, really, but eh):
MyCustomElement = Polymer(
  is: 'my-custom-element',
  properties:
    formAction: String
)

In the browser, the form element is invariably rendered with an action of "http://localhost:4000/store/assets/%7B%7BformAction%7D%7D". In the debugger, I can see the formAction property correctly being set to the expected value. Other bindings and properties work fine, this appears to be specific to this tag/attribute.

Any help appreciated,
-j

 

weipin...@gmail.com

unread,
Jun 29, 2015, 6:36:50 PM6/29/15
to polym...@googlegroups.com
I didn't understand coffeescript, but did notice one issue in your script, you need to pass in an object to Polymer function, and properties also needs to be an object. Please notice the four added curly braces.

MyCustomElement = Polymer( {
  is: 'my-custom-element',
  properties: {
    formAction: String
  }
} )


Julien Silland

unread,
Jun 30, 2015, 1:24:31 AM6/30/15
to weipin...@gmail.com, polym...@googlegroups.com
That's actually one of the syntactic sugar CoffeeScript provides — object declarations may be done without curly braces, and indentation is meaningful. I've simplified this example before posting it here but other bindings declared in my element are working, just this one seems to be ignored.

To check if this wasn't an issue with this property, I've tried binding the form's action to another property and the same thing happened. I'm starting to wonder if this has something to do with Rails – I could totally see the framework altering the HTML output and running some processing on <form> elements, to the point that Polymer can no longer bind on the client side.

-j

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/b14df3d9-35a4-43a9-ae2f-ea4e3ba64bae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages