How to stop conflict between jQuery and jQuery Mobile files on responsive website? -
I am just creating a responsive website for accountability such as desktops, tablets and mobile phones. I have a horizontal menu using a list and for mobile I have been switched to only three lines menu icon when a menu is clicked on the overlay panel
The problem is that when I If the required jQuery file for the mobile overlay panel was brought, the horizontal menu on the second screen size was stopped working. I tried to use jQuery to make a conditional statement, if the width of the screen was under 321, then the script for jQuery would be called using getScript at that point. But it does not seem to recognize this. Can anyone tell me how to fix this problem? I'm quite new on responsive and jquery mobile designs. Thanks
In the header:
& lt; Script src = "scripts / jquery-1.11.1.min .js" & gt; & Lt; / Script & gt; & Lt; Script src = "scripts / jquery.mobile-1.4.2.min.js" & gt; & Lt; / Script & gt; & Lt; Script & gt; $ (Document) .ready (function () {if ($ (window). Width () & lt; 321) {$ ('# wrapper'). CSS ('background-color', '#ccc'); / * $ .getScript ("script / jquery.mobile-1.4.2.min.js"); * /} and {$ ('# wrapper'). CSS ('background color', '# FF');}} ) & Lt; / Script & gt;
My horizontal menu:
& lt; Nav id = "headerNav" class = "lefty" & gt; & Lt; Ul & gt; & Lt; Li & gt; & Lt; A href = "index.html" & gt; Home & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "meal.html" & gt; Food & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "sandwiches.html" & gt; Sandwich & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Neo & gt;
My Mobile Menu:
& lt; Div id = "myPanel" data-role = "panel" data-swipe-off = "correct" data - dismissable = "true" data-condition = "correct"> & Lt; Ul id = "mobile navigation" & gt; & Lt; Li & gt; & Lt; A href = "index.html" & gt; Home & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "meal.html" & gt; Food & lt; / A & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; A href = "sandwiches.html" & gt; Sandwich & lt; / A & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Div & gt;
Solution: Quit JM mobile file
Keep yourself out of the header and use any of these instead:
1.
$ (document) .ready (function () {if ($ (window). Width () & lt; = 320) {$ .getScript ("../script / jquery. Mobile -1.4.2mmps ");}}) & lt; / Script & gt;
2
if (screen.width
check it
if (/ Android | Webios | iphone | ipad | ipod | blackberry | iEmob | opera mini / i.test (navigator user agent)) {// some code ..}
Comments
Post a Comment