Sunday, June 2, 2024
 Popular · Latest · Hot · Upcoming
134
rated 0 times [  135] [ 1]  / answers: 1 / hits: 25878  / 9 Years ago, sun, august 2, 2015, 12:00:00

Iam trying to make a swipeable menu in blogger and this is my code :



<script type=text/javascript src=http://code.jquery.com/jquery-1.9.1.js></script>
<script type=text/javascript src=https://www.googledrive.com/host/0B2Iusn9ixPQ2cFFldHoweXRsWms></script>


<script type=text/javascript>
$(window).load(function(){
$([data-toggle]).click(function() {
var toggle_el = $(this).data(toggle);
$(toggle_el).toggleClass(open-sidebar);
});
$(.swipe-area).swipe({
swipeStatus:function(event, phase, direction, distance, duration, fingers)
{
if (phase==move &amp;&amp; direction ==right) {
$(.container).addClass(open-sidebar);
return false;
}
if (phase==move &amp;&amp; direction ==left) {
$(.container).removeClass(open-sidebar);
return false;
}
}
});
});

</script>


and Iam getting this error at $(.swipe-area).swipe({ : uncaught typeerror $(...).swipe is not a function



PLease Help,
Thanks


More From » jquery

 Answers
44

Try this



<html>
<head>

<script src=http://code.jquery.com/jquery-1.11.3.min.js></script>
<script src=http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js></script>
<script>
$(document).on(pagecreate,#pageone,function(){
$(p).on(swipe,function(){
$(this).hide();
});
});
</script>
</head>
<body>

<div data-role=page id=pageone>
<div data-role=main class=ui-content>
<p>If you swipe me, I will disappear.</p>
<p>Swipe me away!</p>
<p>Swipe me too!</p>
</div>
</div>

</body>
</html>


Update - Unexpected token



There is a syntax error in your code in below line



swipeStatus:function(event, phase, direction, distance, duration, fingers)


Correct syntax - In below way, you can define swipeStatus a function



var swipeStatus  = function(event, phase, direction, distance, duration, fingers)

[#65572] Thursday, July 30, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
felixa

Total Points: 180
Total Questions: 113
Total Answers: 108

Location: Palau
Member since Sat, Aug 21, 2021
3 Years ago
;