Sunday, 15 August 2010

php - Yii2 active form, please wait message while submitting with ajax -


I am using Yii2 advanced template, and display a dialog with the message 'Please wait ...' Looking for a way to do

Here's my active form code:

   is true,)); ? & Gt; & Lt; Fieldset & gt; & Lt ;? = $ Form-> Field ($ Model, 'Username', ['InputApons' = & gt; ['Placeholder' => $ Model-> GetAttributeLabel ('Username'),],]) & gt; Label (wrong); ? & Gt; & Lt ;? = $ Form-> Field ($ model, 'password', ['input options' = & gt; ['placeholder' = & gt; $ model- & gt; getAttributeLabel ('password'),],]) gt; Label (Wrong) - & gt; Password input ()? & Gt; & Lt ;? = $ Form-> Field ($ model, 'meme') - & gt; Checkbox ()? & Gt; & Lt ;? = Html :: submitButton ('Login', ['Class' => 'BTN BTN-LG BTN-Success BTN-Block', 'Name' = & gt; 'Login-Button'])? & Gt; & Lt; / Fieldset & gt; & Lt ;? Php ActiveForm :: end (); ? & Gt;  

and my server side action:

  public function action log () {if!! \ Yii :: $ app- & gt; User- & Gt; isGuest) {Return to $ this- & gt; GoHome (); } $ Model = new LoginForm (); If (Yii :: $ app- & gt; Request-> is Ajax & amp; $ Model-> Load (Yii :: $ app- & gt; Request- & gt; Post ()) {Yii : $ App- & gt; Feedback-> gt; Format = Response: FORMAT_JSON; Return ActiveForm :: validate ($ Model); } If ($ model-> Load (Yii :: $ app- & gt; Request- & gt; Post ()) & amp; $ Model-> Login ()) {Return $ the- & Gt; GoBack (); } And {return $ is-> (render ('login', ['model' =>, $ model,])}}  

I successfully send forms / forms I am confirming but there is a need to display a dialog, so if the connection is slow, then the user will get an idea that the form is actually sending and more time is required to complete. >

for ActiveForm Managed with script (view).

  $ ('# myform'). ('Ajax firsthand', function (event, jqXHR, settings) {// wait the waiting label} ). ('Ajax complete', function (event, jxaxhr, textstatus) {// disable waiting label});  

More detailed information about both of these events given here

ajax firstend:

ajaxBeforeSend event is

signature of event handler Should:

function (events, jqXHR, settings)

Settings: Settings for AJAX requests

ajax full:

The event has been turned on after completing an AJAX request for ajaxcomplete AJAX-based verification. Event handler must be signed:

Function (Event, JXXHR, TextStatus)

Where

  • Event: An Event Object

  • jqXHR: a jqXHR object

  • textstat: "Timeout", "abortion", or "parser").

Also check this, maybe it would be useful for this purpose. / P>


No comments:

Post a Comment