Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
afefcd6e
Commit
afefcd6e
authored
Jan 30, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support form submission by pjax.
parent
1367a7b5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
1 deletion
+9
-1
Pjax.php
framework/widgets/Pjax.php
+9
-1
No files found.
framework/widgets/Pjax.php
View file @
afefcd6e
...
...
@@ -50,10 +50,16 @@ class Pjax extends Widget
/**
* @var string the jQuery selector of the links that should trigger pjax requests.
* If not set, all links within the enclosed content of Pjax will trigger pjax requests.
* Note that
the pjax response to a link
is a full page, a normal request will be sent again.
* Note that
if the response to the pjax request
is a full page, a normal request will be sent again.
*/
public
$linkSelector
;
/**
* @var string the jQuery selector of the forms whose submissions should trigger pjax requests.
* If not set, all forms with `data-pjax` attribute within the enclosed content of Pjax will trigger pjax requests.
* Note that if the response to the pjax request is a full page, a normal request will be sent again.
*/
public
$formSelector
;
/**
* @var boolean whether to enable push state.
*/
public
$enablePushState
=
true
;
...
...
@@ -148,9 +154,11 @@ class Pjax extends Widget
$this
->
clientOptions
[
'timeout'
]
=
$this
->
timeout
;
$options
=
Json
::
encode
(
$this
->
clientOptions
);
$linkSelector
=
Json
::
encode
(
$this
->
linkSelector
!==
null
?
$this
->
linkSelector
:
'#'
.
$id
.
' a'
);
$formSelector
=
Json
::
encode
(
$this
->
formSelector
!==
null
?
$this
->
formSelector
:
'#'
.
$id
.
' form[data-pjax]'
);
$view
=
$this
->
getView
();
PjaxAsset
::
register
(
$view
);
$js
=
"jQuery(document).pjax(
$linkSelector
,
\"
#
$id
\"
,
$options
);"
;
$js
.=
"jQuery(document).on('submit',
$formSelector
, function (event) {jQuery.pjax.submit(event, '#
$id
');});"
;
$view
->
registerJs
(
$js
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment