2014-04-16 18 views
7

Chcę wiedzieć, jak wywołać działania, gdy wejście zostanie koncentruje ..
teraz używam to na moim szablonu: {{view "clickinput" class="form-control" placeholder="search..." value=s action="focus"}}
i to jak widok:Jak wywołać akcję, gdy wejście zostanie skupione?

export default Ember.TextField.extend({ 
    onEvent: 'focusIn', 
    focusIn: function() { 
    this.sendAction('focusIn', this, event); 
    } 
}); 

i to na mój kontroler:

actions: { 
    focus: function() { 
    alert('f'); 
    } 
} 

ale to nie działa ..
otrzymuję ten błąd na chrome: Uncaught Error: Assertion Failed: The focusIn action was triggered on the component <[email protected]:clickinput::ember438>, but the action name (function superWrapper() { var ret, sup = this.__nextSuper; this.__nextSuper = superFunc; ret = func.apply(this, arguments); this.__nextSuper = sup; return ret; }) was not a string.

dlaczego?

Odpowiedz

15

Okazało się prostsze niż myślałem ..
miałem tylko napisać {{input class="form-control" placeholder="search..." value=s focus-in="focus"}} w moim szablonu

-1

kiedyś swoją odpowiedź jako punkt wyjścia tak dzięki! Oto co pracował dla mnie:

statystyki

Ember:

DEBUG: ------------------------------- 
DEBUG: Ember   : 1.7.1 
DEBUG: Ember Data  : 1.0.0-beta.11 
DEBUG: Handlebars  : 1.3.0 
DEBUG: jQuery   : 2.1.3 
DEBUG: Model Fragments : 0.2.7 
DEBUG: ------------------------------- 

Moje funkcje generyczne, wzywam functions.js

Ember.TextField.reopen({ 
    attributeBindings: ['data-stripe'], 
    focusIn: function() { 
    return this.sendAction('focus-in'); 
    } 
}); 

moim kontroler

actions: { 
    focusField: function() { 
     debugger; 
    } 
    } 

My Kierownice szablon

{{input focus-in="focusField" type="tel" maxlength="20" data-stripe="number" placeholder="Card Number" value=input.number autocomplete="cc-number"}} 
Powiązane problemy