Yii Framework Forum: http://inqbus.co/beta - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

http://inqbus.co/beta inQbus - ideas testing hub Rate Topic: -----

#1 User is offline   inqbus 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 30-August 12

Posted 30 August 2012 - 05:46 AM

Hi everyone, I am happy to show you latest web project powered by yii.
We are still in development stage but hopefully we'll be live soon.
Idea is completely fresh and exciting.
You are free to peek in our code on GitHub but since this is my first post I am not allowed to post any links.

http://inqbus.co/beta
1

#2 User is offline   kiran sharma 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 498
  • Joined: 21-May 11
  • Location:India

Posted 30 August 2012 - 07:58 AM

nice one,
+1 for this.
look like pinterest.. :D
Thanks,
Kiran Sharma.
0

#3 User is offline   inqbus 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 30-August 12

Posted 31 August 2012 - 10:18 AM

Thanks Sharma,
If you are interested to know any more details feel free to ask,
in general for front end I am using JQuery and Blueprint css.
I find gii module very helpful, thank you Yii.
However I had some issues with CClientScript, especially whit Ajax requests.
Here is a quick example:

Imagine you are using some of the JQuery plugins, in my case I am using Asual JQuery Address and I am of course registering that script on top of the layout file, here is simplified code:

<?php
Yii::app()->clientScript->registerCoreScript('jquery');
Yii::app()->clientScript->registerPackage('address');
?>
<!DOCTYPE html>
<html>
    <head>
        <title>Simple Layout</title>
    </head>
    <body>
        <div id="div-to-populate-with-ajax-response"></div>
    </body>
</html>


And here is the example of a simple view page that needs to be populated:
<?php
echo $this->widget('zii.widgets.jui.CJuiDatePicker', array(
    'id' => 'date-widget',
    'name' => 'date-widget',
    'model' => $someModel,
    // ...
));
?>


Now here is what happens, if we have this piece of code in controller (assume inline action):
if (Yii::app()->request->isAjaxRequest) {
    $this->renderPartial('_datePicker', array(
        'someModel' => $someModel,
    ));
}


Our date widget is not initialized (scripts are registered but output is not processed).

Of course we have option to use this code instead to trigger output processing:

if (Yii::app()->request->isAjaxRequest) {
    $this->renderPartial('_datePicker', array(
        'someModel' => $someModel,
    ), false, true);
}


But this is where problem exists, any widget that uses client script will register core scripts again,
and JQuery script will be included once more.
This newly included script file once loaded in browser will be evaluated and as a result "$ - jQuery"
object is completely new instance in memory and this time none of the JQuery plugins are available any longer.

I wonder if there is some decent solution for this problem, I had to use some nasty workarounds (manly inline scripts tags).

Oh, and by the way, any feedback or help is greatly appreciated, at the moment we are a little short on man power
(I do all the code + design).
Cheers
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users