Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ember.js

I am upgrading from Ember 1.7 to Ember 1.8.0-beta.2 (incremental upgrade, I hope to reach the latest 1.8.0-beta.4 without much trouble).

Apparently, Ember.TextField is deprecated:

DEPRECATION: Resolved the view "Ember.TextField" on the global context. Pass a view name to be looked up on the container instead, such as {{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 have tried with (as I have done with other views):

{{view "textField" ...}}

No luck:

Uncaught Error: Assertion Failed: textField must be a subclass of Ember.View, not

So, it seems it is now a component. So I try with:

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

And it seems to work, but I am worried that I am maybe doing something wrong, because neither id nor classNames nor placeholderTranslation are listed as supported properties for the input component.

So here my questions:

  • am I right in doing this refactoring {{view Ember.TextField}} -> {{input type="text"}}?
  • what about the properties not explicitly supported? They seem to work in my case. Is this a problem of outdated documentation, or ...
  • is there a list of generic properties supported by all components? I can not find any.
like image 883
blueFast Avatar asked Dec 19 '25 03:12

blueFast


1 Answers

About your questions on ember here is my answer step by step:

  • Yes you are doing right refactoring

    OLD- {{view Ember.TextField}}
    NEW- {{input type="text" value="" name="" class=""}}
    
  • "Class" etc properties are anyways supported by html input so when you will add class, placeholder etc things those will be automatically supported as per my understanding

  • Also all property which are mentioned in Ember Doc other than that whatever 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">
    
like image 171
shinesecret Avatar answered Dec 21 '25 20:12

shinesecret



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!