0

I'm trying to make the sort functionality work by creating two buttons: relevance and date.

I've set it up the following way:

<div ng-init="sort=false">
<a ng-click="sort=true">Date</a>
<a ng-click="sort=false">Relevance</a>

then on the container with the results:

<div eui-sort="ejs.Sort('post_date').order('desc')" eui-enabled="sort" >

The value set with ng-init properly affects the initial sort order and when I click date the list sorts as intended, but when I click relevance the list does not re-sort back as if eui-enabled was set to false.

I'm guessing underformed knowledge of Angular is causing me to oversimplify this. Any advice?

psorensen
  • 809
  • 4
  • 17
  • 33

1 Answers1

1

I suspect you're running into the AngularJS dot-problem, i.e.: the sort. A way to circumvent this is modifying sorting.sort within the eui-sort scope:

<div eui-sort="ejs.Sort('post_date').order('desc')" eui-enabled="true">
<a ng-click="sorting.enabled=true">Date</a>
<a ng-click="sorting.enabled=false">Relevance</a>
</div>

In this example, eui-enabled is only used for initialization since the value (true) doesn't change. Note that to reference the "sorting: object you must be inside the scope of the eui-sort (i.e.: inside the div)

Community
  • 1
  • 1
Yousef
  • 876
  • 6
  • 13
  • did you mean to include `eui-enabled="sorting.enabled"`? Otherwise, I don't follow how the ng-clicks would have any affect on the eui-sort. Also, when I included the sort buttons inside the scope, I experienced the same problem: The sort took place only on the inital click of whatever was set to `ng-click="sorting.enabled=true"` – psorensen Jul 10 '14 at 13:01
  • 1
    No, eui-enabled is actually a shorthand for setting sorting.enabled. Check out [the docs on euiSort and euiEnabled](https://github.com/YousefED/ElasticUI/blob/master/docs/components.md). However, I see now that in the framework the sort is actually not removed when set to false - I hope to provide a fix for this tomorrow (so my initial diagnosis might have been wrong - my bad). If you provide a JSFiddle I'll make sure to test it against that. – Yousef Jul 10 '14 at 20:42
  • 2
    Update: fixed in v0.0.3 – Yousef Jul 14 '14 at 12:01