在Ember 1.13中,我有一个使用Ember.computed.sort的组件:
function custom_single_price_html() {
global $woocommerce,$product, $post;
if ( $product->is_type('simple')) {
$reg_price = $product->get_regular_price();
//working fine for this condition
...
...
}
elseif ( $product->is_type('variable') ) {
$min_price = $product->get_variation_price('min', true);
$max_price = $product->get_variation_price('max', true);
$display_price_min_max = '<span class="sale-price">'.wc_price($min_price).' - '.wc_price($max_price). '</span>';
return $display_price_min_max;
}
else {
return;
}
}
add_action('woocommerce_get_price_html', 'custom_single_price_html');
我需要访问组件的columnList属性以自定义提供给Ember.computed.sort的比较函数的行为。如何在上面的代码指示的位置访问比较函数内部的columnList?
答案 0 :(得分:0)
如果cloumnList
属性位于与您使用component
相同的Ember.computed.sort
下,则只需使用this.get('columnList');
访问columnList
属性
...
sortedItems: Ember.computed.sort("allItems", function(a, b) {
this.get('columnList');
}),
...