watusi / jquery-mobile-iscrollview

JQuery Mobile widget plug-in for easy use of the iScroll javascript scroller.
408 stars 183 forks source link

Problem with requirejs optimization #63

Open lpfister opened 11 years ago

lpfister commented 11 years ago

Hello,

Is this library compatible with requirejs optimization r.js?

When I do an optimization, i get an error at this line

JQMIsV1_0 = $.mobile.ignoreContentEnabled === undefined,

Telling me that $.mobile is undefine

But in my main.js I used shim to

jqmIscroll: { deps: ['jqm', 'iscroll'] },

And it works correctly when I do not do optimization

Thanks in advance

Loic

marcorinck commented 11 years ago

I have the same problem with requirejs. If all require modules are loaded seperately and asynchrons it works (as in development mode), but after requirejs is used to produce one big file where jquery, jquery mobile and iscrollview are appended together in the correct order (as in production mode), it doesn't work anymore.

The problem appears to be, that at the time of parsing the iscrollview code, the $.mobile object doesn't exist yet.

Currently I don't have a plan how to fix that. I assume it has something to do with the jquery ready event.

lpfister, have you solved it in the mean time?

Thanks.

Marco

lpfister commented 11 years ago

Hey Marco,

I do not remember how I solve this issue.

I remember tho it was nothing to do with iscroll.

I think the issue was with some capital letter somewhere, so basically the optizmation stopin the middle but I did not see it.

My suggestion double check the speeling of all your included library.

Then remove all your library in js exepect iscroll, then add it again one by one and you will see which one is the issue .

lpfister commented 11 years ago

Btw this comment can be closed for me :)

marcorinck commented 11 years ago

Unfortunately there is no type, the problem is like I said the loading order and the order of initialization of jquery, jquery mobile and this plugin.

I ended up converting this plugin to an amd module by myself, putting all of the code of this plugin into a function that is only called after the pagecreate event happend. That event is already bound and some late init stuff is already done there, I only added a call the my new function and do all of the initialization there. So the initialization of this plugin happens consistently after jquery and most importantly after jquery mobile.

Its now working in both modes: each module separately and in one big file after optimization.

njtman commented 11 years ago

I am having this same issue right now. I saw your answer on SA, http://stackoverflow.com/questions/14609894/load-jquery-mobile-iscrollview-with-requirejs-optimizer/14641888#14641888

I followed the directions in your post and was able to get my app to optimize and run. The issue I am having now though is relating to screen orientation change. It seems like the iscroller is not getting updated after changing the screen orientation. Any ideas? Did you run into this issue?

jcalonso commented 11 years ago

Any plans to convert this lib to be AMD compilant?

jtara commented 11 years ago

I have no such plans myself.

I'm open to pull requests.