Frage

am using yii-user extension for registration. it works perfect .but my reqiurement is to render the registration form using ajax on pages with menu ,which contains this register as menuitem .i dont want is user to be redirected to some other page. my need is on whichever page she may be she can register from their via ajax registration form on that particular page

  array('url'=>Yii::app()->getModule('user')->registrationUrl, 'label'=>Yii::app()->getModule('user')->t("Register"), 'visible'=>Yii::app()->user->isGuest),

this wrks and redirects me to user/registration page but my need is ajax popup up on any page when register item is clicked.

i did something like and in script

    function showmod()
{




 document.getElementById("showdata").style.display = "block";


 //alert("hi1");

 //  alert("hi");
    var xmlhttp;    

    if (window.XMLHttpRequest)
         {// code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp=new XMLHttpRequest();
         }
      else
     {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
   }
 xmlhttp.onreadystatechange=function()
  {
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
     {
    // alert("hi2");
    document.getElementById("showdata").innerHTML=xmlhttp.responseText;

//alert("h2");
  }
   }
   xmlhttp.open("GET","<?php echo Yii::app()->getModule('user')->registrationUrl ;?>",true);

    //alert("h1");


   xmlhttp.send();

    }

  array( 'url'=>'#','label'=>Yii::app()->getModule('user')->t("Register"), 'visible'=>Yii::app()->user->isGuest,array('click'=>"showmod()")),

doesnt work

a similar post i have posted https://stackoverflow.com/questions/22164620/yii-user-registration-view-in-model-window

as its been extracted in module folder .might be thats error i dont what is it please let me know

can anyone please help ,guide,suggest how do achieve so

War es hilfreich?

Lösung

here instead of

          xmlhttp .open("GET","<?php echo Yii::app()->getModule('user')->registrationUrl ;?>",true);

this wrks

    xmlhttp.open("GET","<?php echo Yii::app()->request->baseUrl;?>/index.php/user/registration",true);

Andere Tipps

Using Bootstrap inbuilt css files we can do popus..

<script type="text/javascript">
        $( document ).ready(function() {
        $('#opn').trigger("click");
        $('#myModal').on('hide', function (e) {
        window.location.href = "<?php echo Yii::app()->createUrl('product/admin'); ?>"
           });


        });</script>


<button class="btn btn-primary btn-lg" id="opn" style="margin-top: 30%; display:none" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>

<!-- Modal -->

<div class="modal fade product" style="width:1000px; id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
///your form

</div>

modal fade is inbuilt CSS CLASS if you are using bootstrap..

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top