jquery mobile document ready with pageshow
<p><a href="http://www.youtube.com/watch?v=zKI-eJuaSg8&amp;feature=youtu.be" rel="nofollow">http://www.youtube.com/watch?v=zKI-eJuaSg8&amp;feature=youtu.be</a></p>

<p>I make Swipe action javascript with my jQuery Mobile framework</p>

<p>first time page loaded, not firing
'pageshow' event, so I added document ready </p>

<p>but this source is just duplicate code.</p>

<p>how to make simple code this?</p>

<pre><code>&lt;script type="text/javascript"&gt;
    $(document).ready(function(){
            var pageid = $.mobile.activePage.attr("id");
            pagenum = parseInt(pageid.charAt(4)) + 1;
            nextpagenum = pageid.substring(0,4)+pagenum;
            // Swipe Left
            $('#'+pageid).bind('swipeleft',function(event){
                $.mobile.changePage('#'+nextpagenum,"slide","reverse")
                $('#eventlog').append('swipeLeft')+parsingDate(new Date())+'&lt;br/&gt;'.css("color","red")
            });
    });
&lt;/script&gt;
&lt;script type="text/javascript"&gt;
    $(function() {
        $("section[data-role*='page']").live('pageshow', function(event, ui) {
                var pageid = $.mobile.activePage.attr("id");
                pagenum = parseInt(pageid.charAt(4));
                var prevpage = pageid.substring(0,4) + (pagenum-1);
                var nextpage = pageid.substring(0,4) + (pagenum+1);

                // Swipe Right
                $('#'+pageid).bind('swiperight',function(event){
                    $.mobile.changePage('#'+prevpage,"slide","reverse")
                });
                // Swipe Left
                $('#'+pageid).bind('swipeleft',function(event){
                    $.mobile.changePage('#'+nextpage,"slide","reverse")
                });
            });
    });
&lt;/script&gt;
</code></pre>

<p>full source is <a href="https://github.com/pcjpcj2/jQuery-Mobile-snippets/tree/master/Swipe" rel="nofollow">https://github.com/pcjpcj2/jQuery-Mobile-snippets/tree/master/Swipe</a></p>

<p>i want write the code 'Swipe Left' just one time.</p>

<p>although full function works.</p>
