Jomia
Jomia

Reputation: 3404

Can I listen for any kind of event in splash screen using jquery or jquery mobile

I want to display a splash screen in my app. This splash screen should disappear by any user event or after 5 second.

I went through some articles that we can listen for events, but we should specify the event name there. Is there any way that I can listen for any kind of event?

Upvotes: 2

Views: 117

Answers (1)

Phill Pafford
Phill Pafford

Reputation: 85318

Does something like this work?

JS:

function bindEventTouch(element) {
    element.bind('tap taphold swipe swiperight swipeleft', function(event, ui) {
       alert('Event: '+event.type); 
    });
}

// List of events: http://api.jquery.com/category/events/
function bindEvents(element) {
    element.bind('click change dblclick submit', function(event) {
        alert('Element Id: '+$(element).attr('id')+' Event: '+event.type);
    });
}

//bindEventTouch($('#display-event'));
//bindEvents($('#display-event'));

$('.displayEvent').each(function(){
    bindEvents($(this));
});

HTML

<div data-role="page" id="home"> 
    <div data-role="content">
        <div id="display-event-1" class="add-border displayEvent">
            <p>Tap, TapHold (for 1 second), Swipe, SwipeRight or SwipeLeft</p>
        </div>
        <br />
        <div id="display-event-2" class="add-border displayEvent">
            <p>Tap, TapHold (for 1 second), Swipe, SwipeRight or SwipeLeft</p>
        </div>
        <br />
        <div id="display-event-3" class="add-border displayEvent">
            <p>Tap, TapHold (for 1 second), Swipe, SwipeRight or SwipeLeft</p>
        </div>
    </div>
</div>​

Upvotes: 2

Related Questions