PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, February 15, 2022

[FIXED] how to assign the data result of ajax response of cgridview custom button's click event to a php variable in yii 1.x?

 February 15, 2022     jquery, yii     No comments   

Issue

I have a custom button in CGridView. There's a click event where by I have to pass the id of the row to the controller action in order to do a query.

             'options' => array(
                 'ajax' => array(
                    'type' => 'POST',
                     'url' => "js:$(this).attr('href')",
                     'success' => 'function(data){
                            $("#detail").html(data);
                            $("#detail-dialog").dialog("open"); return false;
                        }',
                     'update' => '#detail'
                 )
             )

Once I get the result from the controller action, I open a dialog box. I want to have that data assigned to a PHP variable because I will need it in order to loop and create a CJuitabs inside the CJuiDialog. instead of doing $("#detail").html(data);

In the same file uner the CGridView, I have this CJuiDialog script that pops out.

    $this->beginWidget('zii.widgets.jui.CJuiDialog', array(
        'id' => 'detail-dialog',
        'options' => array(
            'title' => 'Dialog Box Title' . $data->id,
            'autoOpen' => false,
            'modal' => true,
            'width' => 550,
            'height' => 450,
        ),
    )); ?>

<div id="#detail></div>
<?php
$this->endWidget();
?>

I want to put CJuitabs inside that CJuiDialog and I need to loop some data for producing the number of tabs dynamically.

How do I assign that ajax data to a php variable ?


Solution

I solved my problem by generating the whole CJuiTabs from the controller and fed the view file that calls a javascript that fires the CJuiDialog box



Answered By - sasori
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing