Jester and classes?

13 views
Skip to first unread message

nosarious

unread,
Nov 19, 2010, 3:18:53 AM11/19/10
to Jester JS
I have a list of images I am trying to tap on, but the timing of the
taps are a bit awkward, especially since one swipes the list to see
the different ones.

The syntax of these is on multiple elements, each with a class instead
of an id.

The current 'working' version is here:
http://straathof.acadnet.ca/beta7.9

The jester javascript I have so far (which is not working... see
beta8.0 )is this:

var article_selection =$('#issue>a')[0];
var change_article = function(touches) {
alert("this is a click!");
//reset the dimensions of the page.
//updateOrientation();
//hide all articles in issue_content at beginning
$('#issue_contents>div').css('position','absolute').hide();
$(this).find('img').addClass('selected');
//show the article quickly
$
('#issue_contents>div').filter(this.hash).addClass('active').fadeIn(500);
//show the article content slowly
$
('#issue_contents>div').filter(this.hash).find('.article_content').fadeIn(500);
// $('#issue').addClass('hidden');
return false;
//updateOrientation();
};


The javascript which does work (but which is tied to touchstart) is:

$('#issue>a').bind('touchstart click', function() {
//change the state of the selected icon to
'selected' (indented)
$(this).find('img').addClass('selected');
//show the article quickly
$
('#issue_contents>div').filter(this.hash).addClass('active').fadeIn(500);
//show the article content slowly
$
('#issue_contents>div').filter(this.hash).find('.article_content').fadeIn(500);
// $('#issue').addClass('hidden');
return false;
//updateOrientation();
});

Any help would be great! I have several gestures in jester that would
be awesome to use for the different articles!

nosarious

unread,
Nov 19, 2010, 6:06:04 PM11/19/10
to Jester JS
I fixed my own problem and hope the answer will help others working on
this kind of problem:

//assign a jester tap to all icons
var aIcons=[];
var aSelection =$(".icon");
for(var i=0; i<aSelection.length;i++){
jester(aSelection[i])
.tap(function(touches){
$(this).find('img').addClass('selected');
return false;
});
};

This cycles through a bunch of classes with the same '.icon' name and
adds a class named 'selected' to the element.
Reply all
Reply to author
Forward
0 new messages