Uncaught TypeError: Cannot use 'in' operator to search for '111' in ["dd","a","b","d","e","f","g"] , typeahead - typeahead

According to the Typeahead and some examples found here. i keep geting error Uncaught TypeError: Cannot use 'in' operator to search for '111' in ["dd","a","b","d","e","f","g"]
<input id="searchDeveloper" class="typeahead" type="text" placeholder="countries"/>
$('#searchDeveloper').typeahead({
name: 'countries',
prefetch: '/search',
limit:10
});
What am I doing wrong? Thanks :)

Related

How to use function with arguments in IF statement in the template

Currently Im trying to use a function that observes a field of a controller/component in ember template (handlebars).
index.hbs
<div>
{{ input value=model.field1 }}
{{if hasFieldError('field1')}}
<span>This field is required</span>
{{/if}}
</div>
<div>
{{ input value=model.field2 }}
{{if hasFieldError('field2')}}
<span>This field is required</span>
{{/if}}
</div>
index.js
hasFieldError: function(val) {
return true if val is found in an array
}.observes('field1', 'field2'),
But this of course returns a build error:
{#if hasFieldError('compa ----------------------^ Expecting
'CLOSE_RAW_BLOCK', 'CLOSE', 'CLOSE_UNESCAPED', 'OPEN_SEXPR',
'CLOSE_SEXPR', 'ID', 'OPEN_BLOCK_PARAMS', 'STRING', 'NUMBER',
'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', 'SEP', got 'INVALID'
Any idea how to achieve this?
You can't call a function from a template, except using an action. You can only reference properties, such as fields and computed properties.
Observers are generally not a good idea
Are you really trying to determine if the value of field1 is in an array? Let's assume the array is found at array1. Then you could write a helper named contains:
{{#if (contains array1 field1)}}
But someone has already written this. Welcome to the wonderful Ember community of addons! See https://github.com/DockYard/ember-composable-helpers#contains
Just replace your observer function with a computed property:
hasFieldError: Ember.computed('field1', 'field2', function(val) {
return true if val is found in an array
}),

Ember-paper: Cannot set property element of [object Object] which has only a getter

I am using Ember-paper 0.2 which seems to be latest stable version.
i'm creating navbar learning from tutorial. whenever I add paper-button i am getting error " Cannot set property element of [object Object] which has only a getter".
It looks like i have mistaken some where but not able to figure out what.
Below is my code for navbar.
{{#paper-toolbar}}
<div class="md-toolbar-tools">
{{logo}}
<div class="paper-right">
{{#paper-button size="2"}} {{paper-icon "refresh"}} {{/paper-button}}
</div>
</div>
{{/paper-toolbar}}
{{outlet}}
{{logo}} is my logo component below is the component code
<img src="assets/images/logo_sm_app.png" class="logo">
I have defined my styles in app.scss file
I have used steps as stated in the ember-paper documentation. Could you please tell me what is missing?
Below is the stack trace of the error i am getting
Uncaught TypeError: Cannot set property element of [object Object] which has only a getter
at Class.didInsertElement (ripple-mixin.js:31)
at Class.superWrapper [as didInsertElement] (ember.debug.js:40424)
at Class.trigger (ember.debug.js:42259)
at Class.superWrapper [as trigger] (ember.debug.js:40424)
at CurlyComponentManager.didCreate (ember.debug.js:12725)
at Environment.commit (ember.debug.js:50904)
at Environment.commit (ember.debug.js:9283)
at InteractiveRenderer._renderRoots (ember.debug.js:12121)
at InteractiveRenderer._renderRootsTransaction (ember.debug.js:12150)
at InteractiveRenderer._renderRoot (ember.debug.js:12071)

Ember.js this.set() not working from inside action

Folks, I'm having some beginner problem and would love some assistance. This is in ember 2.6 if it makes any difference. Basically, I'm trying to change some text on the screen when the button is pressed inside a component. Here's the handlebars and component js code:
<h2>Stupid Button</h2>
<div>
<form id="sign_in_form" {{action 'triggerTheAction' on='submit'}}>
<button id="signin" type="submit">FIRE!</button>
{{someTextThatShouldChange}}
</form>
</div>
And the component's js code:
export default Ember.Component.extend({
someTextThatShouldChange: 'Initial Value',
actions: {
triggerTheAction: (email, password) => {
alert('alerts just fine');
this.set('someTextThatShouldChange', 'New value for text!');
}
}
});
The error I get in console:
TypeError: _this.set is not a function
Really appreciate the help. I have a feeling I'm just not understanding something fundamental about Ember.
You are using an arrow function to define the action handler. This means that it's binding this to the outer scope, which in your case is the ES6 module. By the specification, a module's this is undefined.

How do you add dynamic partial by concatenating strings in ember js?

We can add partials onto templates in ember js.
{{#each subdetail in leftSubDetails}}
{{partial 'lists/details/link-'+subdetail}}
{{/each}}
Gives following error
Error: Parse error on line 22:
...lists/details/link-'+subdetail}}
-----------------------^
Expecting 'CLOSE', 'CLOSE_UNESCAPED', 'STRING', 'INTEGER', 'BOOLEAN', 'OPEN_SEXPR', 'CLOSE_SEXPR', 'ID', 'DATA', got 'INVALID'
Compute the name of the partial as in the view or controller:
partialName: function() {
return 'lists/details/link/ + this.get('subdetail');
}.property('subdetail')
Then call it like
{{partial partialName}}
Not tested.
Try passing a parameter instead, like this:
{{partial 'lists/details/link' subdetail=blah}}

Ember.Select not working?

I'm working off of sample code from http://emberjs.com/api/classes/Ember.Select.html and it doesn't appear to be working? I get this error:
Assertion failed: The value that #each loops over must be an Array. You passed names ember.js:394
Uncaught TypeError: Object names has no method 'addArrayObserver'
Here's my jsbin: http://jsbin.com/kogav/1/
Thanks for any help
Change it to
{{view Ember.Select contentBinding="names"}}
See http://jsbin.com/gocel/1/