如何从emberjs中的其他元素中删除类

时间:2017-08-02 13:37:01

标签: ember.js

我的函数在点击一个元素时切换类名。但它并没有从其他元素中删除类名。所以现在所有元素都很高兴。但是每当用户点击一个元素时,它应该让fun <T : Any> evaluateJsFromNative(command: String, webView: WebView, klass: Class<T>, function: (value : Any?) -> Unit ) { webView.evaluateJavascript("(function() { return $command; })();") { s -> if (s.convert(klass) != null) function(s.convert(klass)!!) } } fun <T> String.convert(klass: Class<T>) : Any? { when (klass.name.toString()) { "boolean" -> return this.toBoolean() else -> return null } } // call it like this... evaluateJsFromNative(mycommand, mywebview, Boolean::class.java) { Log.d("SomeTag","Value=$it") } 其他兄弟姐妹必须删除classname该怎么做?

这是我的尝试但不起作用:

classname

更新 对于我的要求描述不好,我很抱歉。我已使用import Ember from 'ember'; export default Ember.Component.extend({ isSelected : false, deSelectOthers : function(){ this.set( "isSelected", false ); //deselecting all before add the class to clicked element }, actions : { selectCard : function(card) { this.deSelectOthers(); //de select others not works this.toggleProperty('isSelected'); // add class to this element only works. how to remove class from other element? } } }); 创建了该要求 - 只是如何使用jQuery实现相同的要求? Demo-Requirement

1 个答案:

答案 0 :(得分:1)

以下是working twiddle

您需要维护selectedIndex / value并使用if check来根据selectedIndex / value更新类。

application.hbs

import Ember from 'ember';
export default Ember.Route.extend({
  model(){
    return [1,2,3,4];
  }
});

路由/ application.js中

import Ember from 'ember';
export default Ember.Controller.extend({  
  selectedIndex:undefined,
  actions:{
    changeSelectedIndex(index){
      this.set('selectedIndex',index);
    }
  }
});

控制器/ application.js中

ember install ember-truth-helpers

您需要运行Sub Gender() Dim lr As Long, i As Long Dim x, y() lr = Cells(Rows.Count, 1).End(xlUp).Row x = Range("A2:A" & lr).Value ReDim y(1 To UBound(x, 1), 1 To 1) For i = 1 To UBound(x, 1) If x(i, 1) = "Male" Then y(i, 1) = "M" ElseIf x(i, 1) = "Female" Then y(i, 1) = "F" Else y(i, 1) = "NULL" End If Next i Range("F2").Resize(UBound(y), 1).Value = y End Sub

来安装ember-truth-helpers插件