opitzconsulting / jquery-mobile-angular-adapter

jquery mobile angular adapter
MIT License
517 stars 114 forks source link

bi-directional data-binding not working with jqm panel #226

Open asgeo1 opened 10 years ago

asgeo1 commented 10 years ago

Hi @tigbro,

The docs say the data-opened attribute can be used for two-way data-binding for opening and closing a jqm panel.

It's true, it does work (in one direction at least) to open and close the panel when you change that property.

However, if the panel closes of it's own accord (e.g. swipe gesture), then the variable bound to data-opened is not updated, and is then out of sync with the state of the panel.

Have you noticed that?

I tried to create you a jsfiddle, but it doesn't initialise properly and doesn't run :( But you will get the gist.

http://jsfiddle.net/jKvwV/11/

thanks, -adam

tbosch commented 10 years ago

Hi, this should work and I have tests for it! Will look into this not until next week, sorry...

Tobias

Am 05.09.2013 um 00:19 schrieb Adam George notifications@github.com:

Hi @tigbro,

The docs say the data-opened attribute can be used for two-way data-binding for opening and closing a jqm panel.

It's true, it does work (in one direction at least) to open and close the panel when you change that property.

However, if the panel closes of it's own accord (e.g. swipe gesture), then the variable bound to data-opened is not updated, and is then out of sync with the state of the panel.

Have you noticed that?

I tried to create you a jsfiddle, but it doesn't initialise properly and doesn't run :( But you will get the gist.

http://jsfiddle.net/jKvwV/11/

thanks, -adam

— Reply to this email directly or view it on GitHub.

asgeo1 commented 10 years ago

Hi @tigbro,

I can see the issue now. I had attached my data-binding variable to $rootScope.

But it only works when it's attached to $scope. Not sure why that is - I thought $scope would have inherited from $rootScope.

AngularJS is a bit confusing :)

I did kind of want the data-binding variable on $rootScope though, as $rootScope is one way I can pass data/state between jqm pages.

I was trying to keep track of whether the panel was last in an opened/closed state as I moved to to/from the jqm page with the panel.