Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
moved our form binding into the _registerInternalEvents callback, to …
Browse files Browse the repository at this point in the history
…ensure it's not bound until after mobilinit.
  • Loading branch information
scottjehl committed Jun 22, 2011
1 parent 68a354e commit a43ce64
Showing 1 changed file with 30 additions and 31 deletions.
61 changes: 30 additions & 31 deletions js/jquery.mobile.navigation.js
Expand Up @@ -926,37 +926,6 @@
};

/* Event Bindings - hashchange, submit, and click */

//bind to form submit events, handle with Ajax
$( "form" ).live('submit', function( event ) {
var $this = $( this );
if( !$.mobile.ajaxEnabled ||
$this.is( ":jqmData(ajax='false')" ) ) {
return;
}

var type = $this.attr( "method" ),
url = path.makeUrlAbsolute( $this.attr( "action" ), getClosestBaseUrl($this) ),
target = $this.attr( "target" );

//external submits use regular HTTP
if( path.isExternal( url ) || target ) {
return;
}

$.mobile.changePage(
url,
{
type: type.length && type.toLowerCase() || "get",
data: $this.serialize(),
transition: $this.jqmData( "transition" ),
direction: $this.jqmData( "direction" ),
reloadPage: true
}
);
event.preventDefault();
});

function findClosestLink( ele )
{
while ( ele ) {
Expand Down Expand Up @@ -986,6 +955,36 @@
//The following event bindings should be bound after mobileinit has been triggered
//the following function is called in the init file
$.mobile._registerInternalEvents = function(){

//bind to form submit events, handle with Ajax
$( "form" ).live('submit', function( event ) {
var $this = $( this );
if( !$.mobile.ajaxEnabled ||
$this.is( ":jqmData(ajax='false')" ) ) {
return;
}

var type = $this.attr( "method" ),
url = path.makeUrlAbsolute( $this.attr( "action" ), getClosestBaseUrl($this) ),
target = $this.attr( "target" );

//external submits use regular HTTP
if( path.isExternal( url ) || target ) {
return;
}

$.mobile.changePage(
url,
{
type: type.length && type.toLowerCase() || "get",
data: $this.serialize(),
transition: $this.jqmData( "transition" ),
direction: $this.jqmData( "direction" ),
reloadPage: true
}
);
event.preventDefault();
});

//add active state on vclick
$( document ).bind( "vclick", function( event ) {
Expand Down

0 comments on commit a43ce64

Please sign in to comment.