Going from {{view Ember.TextField}} to {{input type = "text"}}

I am upgrading from Ember 1.7 to Ember 1.8.0-beta.2 (incremental upgrade, I hope you can reach the latest 1.8.0-beta.4 without any problems).

Apparently Ember.TextField is deprecated :

DEPRECATION: allowed to view "Ember.TextField" on the global context. Pass in the name of the view to be displayed on the container instead, for example {{view "select"}}. http://emberjs.com/guides/deprecations#toc_global-lookup-of-views-since-1-8

This is my original implementation:

{{view Ember.TextField classNames="form-control" valueBinding="properties§name" id="name-id" placeholderTranslation="generic.name" required="true"}}

      

So, I tried with (as I did with other views):

{{view "textField" ...}}

      

Bad luck:

Unprepared error: Assertion failed: textField must subclass Ember.View, not

So now this is a component. So I try:

{{input type="text" classNames="form-control" value=properties§name id="name-id" placeholderTranslation="generic.name" required="true"}}

      

And it seems to work, but I'm worried that I might be doing something wrong because it is neither id

, nor classNames

, nor placeholderTranslation

listed as supported properties for the component input

.

So here are my questions:

  • Am I right in this refactoring {{view Ember.TextField}}

    {{input type="text"}}

    ?
  • what about properties not explicitly supported? They seem to work in my case. Is it a problem with outdated documentation or ...
  • Is there a list of common properties supported by all components? I can not find.
+3


source to share


1 answer


About your questions on ember, here's my answer step by step:



  • Yes, you are doing the right refactoring

    OLD- {{view Ember.TextField}}
    NEW- {{input type="text" value="" name="" class=""}}
    
          

  • Properties of the "class", etc. are always supported by html input, so when you add a class, placeholder, etc., they will be automatically supported as per my understanding.

  • Also all the properties mentioned in the Ember Doc , except what is supported in html will always work. You can read the Comment mentioned in ember Ember Source Code

    {{input type="text" value="111" name="mytest" class="icon" id="wow"}}
    
    AND I got
    
    <input id="wow" class="ember-view ember-text-field icon" type="text" 
    name="mytest" value="111">
    
          

+2


source







All Articles