Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

on-select-all="fSelectAll()" #307

Open
karthicjayaraman opened this issue Jun 26, 2015 · 20 comments
Open

on-select-all="fSelectAll()" #307

karthicjayaraman opened this issue Jun 26, 2015 · 20 comments

Comments

@karthicjayaraman
Copy link

output-model is not updated when using on-select-all property.

It would be very helpful for me if you could provide how to get the length of the output-model when select the " on-select-all" option.

@isteven
Copy link
Owner

isteven commented Jun 29, 2015

Hi @karthicjayaraman ,

Can you please help to replicate the problem in JsFiddler or Plunker?

@JeffreyATW
Copy link

Can reproduce here. The output model is updated, but only AFTER the on-select-all callback has occurred. We need to do a $watch on the output model instead, which to me seems dirty.

@isteven
Copy link
Owner

isteven commented Jul 1, 2015

@JeffreyATW ,

I see.. so in other words, during on-select-all callback, the output-model is NOT YET updated (still showing old values)?

Does this also happen in on-select-none?

  • Edit: I prefer not to $watch output-model here.. There are 2 $watches inside the code and I believe it's enough.

@JeffreyATW
Copy link

Yes, happens in both.

@isteven
Copy link
Owner

isteven commented Jul 1, 2015

@JeffreyATW , @karthicjayaraman

Thanks for the info. This is what I'm afraid most.. it happened before, and it forced me to use the $timeout. I'll see what I can do about this.

@karthicjayaraman
Copy link
Author

Great .. Thanks a lot for the response .

On Wed, Jul 1, 2015 at 1:59 AM, Steven notifications@github.com wrote:

@JeffreyATW https://github.com/JeffreyATW , @karthicjayaraman
https://github.com/karthicjayaraman

Thanks for the info. This is what I'm afraid most.. somehow the changes is
not yet reflected back at the controller. I'll see what I can do about this.


Reply to this email directly or view it on GitHub
#307 (comment)
.

@lenczykt
Copy link

I had the same issue but it is solved when you specify property of what should be updated in output model:

output-properties="id name ticked"

@JeffreyATW
Copy link

Nope, we have that set. It works for on-item-click but not on-select-all or on-select-none.

@isteven
Copy link
Owner

isteven commented Jul 30, 2015

Hi all,

Sorry but my current project leaves me almost no time to update the directive.

@JeffreyATW , does $watch-ing the output-model work?

@JeffreyATW
Copy link

Yes.

@prabuinet
Copy link

changing a line worked for me.

this line: $scope.onSelectAll();

to this:

$timeout( function() {
$scope.onSelectAll();
}, 0 );

@isteven
Copy link
Owner

isteven commented Oct 28, 2015

Hi all,

I recently hit similar problem in a complex page, and, after browsing around, one possible solution is simply to add child object on the output-model, like this:

<isteven-multi-select
    input-model="someData" 
    output-model="awesomeOutput.data"    // Add .data
    tick-property="status" 
    on-select-all="showSelected()" 
    ....

Then in your controller, as usual:

$scope.showSelected = function() {
    console.log( $scope.awesomeOutput.data );
}

I hope this helps.

@prabuinet ,
I personally don't think the $scope.onSelectAll() function should be enclosed within $timeout as it does not involve complex DOM operation (it's just a button click afterall). But hey, as long as it solves the problem 😎 👍

Further reading: http://juristr.com/blog/2014/11/learning-ng-databinding-doesnt-work/

@astropcrb
Copy link

I am still having issue with this for both the select-all and select-none. Has it not been resolved? If not, what $watch statement do you recommend?

Thanks.

@isteven
Copy link
Owner

isteven commented Feb 26, 2016

@astropcrb ,

Does adding child object on the output-model work for you?

<isteven-multi-select
    input-model="someData" 
    output-model="awesomeOutput.data"    // Add .data
    tick-property="status" 
    on-select-all="showSelected()" 
    ....

Then in your controller, as usual:

$scope.showSelected = function() {
    console.log( $scope.awesomeOutput.data );
}

@CaptainYouz
Copy link

Hi !

I also have the same problem, but only for on-select-all.
I tried your solution by adding a child object and a log in the controller, but it does not work for me.

Any update :) ?

@mgalic
Copy link

mgalic commented Apr 28, 2016

Thanks for the great directive but I am still having issue with this for both the select-all and select-none. Any plans on fixing this?

@ctcudd
Copy link

ctcudd commented Jul 19, 2016

Here's a fix for this issue: #461

@ghost
Copy link

ghost commented May 9, 2017

Any ideas what is best way to intercept click event on "Select All" button?
As I read few comments above, using another $watch will make my code stink.

What I want to achieve, is catch click event on "Select All" button and either accept if some conditions are met or block and reject the operation of selecting all objects.

Docs for on-select-all states:

A $scope function to call when "select all" button is clicked. You need to define this function in your controller.

but it's not clear to me, the callback on-select-all is triggered before, at the same time or after the item is clicked?

@isteven
Copy link
Owner

isteven commented May 9, 2017

@aryniec,

It's triggered after all items' selection property is set to TRUE.

Generally speaking, all events are triggered after the selection changes happen.

@ghost
Copy link

ghost commented May 10, 2017

@isteven then what would be best way to intercept this "Select All" click, both Angular 1.5 and angular-multi-select way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants