Yii Framework Forum: errors inside jquery.yiigridview.js - Yii Framework Forum

Jump to content

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

errors inside jquery.yiigridview.js Rate Topic: -----

#1 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 09 October 2011 - 03:14 AM

You have there code like
$(settings.updateSelector).die('click').live('click',function(){


but it dont help... the click events will add again and again...

die works only in the same block the click event was attached
more about that here
http://www.alfajango...y-live-and-die/

also here you have the way to solve it
http://www.yiiframew...ata-send-issue/

you need to atach to some part of the page some tag, and dont bind click again...
cause it is causing a lot of problems!
0

#2 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 09 October 2011 - 03:24 AM

example of issue solved:

if(settings.ajaxUpdate.length > 0 && jQuery('body').attr('yiigridview_event1') !== '1') {
					jQuery('body').attr('yiigridview_event1', '1');
					$(settings.updateSelector).die('click').live('click',function(){
						$.fn.yiiGridView.update(id, {url: $(this).attr('href')});
						return false;
					});
			}

0

#3 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 09 October 2011 - 03:30 AM

here I did all the dirty job

https://gist.github.com/1273455

tested, it solves the issues

but I think the problem accure in additional places...

You cant use die('click') it is just not working as you might think
0

#4 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,428
  • Joined: 17-January 09
  • Location:Russia

Posted 09 October 2011 - 06:43 PM

dckurushin
Probably you can put together a demo when current behavior is a problem and describe it? Currently I don't quite get it.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#5 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 10 October 2011 - 01:49 AM

samdark

if you add ajaxLink, and update some div with data you load.

For example you load CGridView with data...

so every time you push the link, the gridView loaded BUT - the events add up.

This is a mistake:
$(settings.updateSelector).die('click').live('click',function(){

You can't do die('click') it is wrong and not working.
you can remove it cause it do nothing and not solves the issues it should

--

so as I said every itme you replace the data in some #ajaxDiv the event add up...
Witch events?

The pagination...
After prassing again and again on the ajaxLink after some CGridView loads, every time you paginate, for example you pushed 10 times on ajaxLink, in pagination it will send 10 requests.

if you push delete, it will send 10 times confirmation message, and potentially 10 times the request...

---

FOr demo you could just create some CArrayDataProvider with $_SERVER data

and load it into div via ajaxLink ... replace => #ajaxDiv
dont forget to add the CButtonColumnm and turn on firebug to see that pagination will send trillion requests after few pushes on ajaxLink...


---

There is also issue with ajaxSubmitButton...
they just not meant to work - loaded via ajax into some element.
0

#6 User is offline   alex-w 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 223
  • Joined: 25-November 10

Posted 10 October 2011 - 10:58 AM

What's the value of settings.updateSelector, is it non default?
0

#7 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 10 October 2011 - 12:03 PM

View Postalex-w, on 10 October 2011 - 10:58 AM, said:

What's the value of settings.updateSelector, is it non default?


it doesnt matters ...
0

#8 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 10 October 2011 - 06:21 PM

if it is not clear, I will upload some example...
0

#9 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,428
  • Joined: 17-January 09
  • Location:Russia

Posted 12 October 2011 - 12:15 PM

That would be great.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#10 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 13 October 2011 - 03:16 AM

Actually it is a little bit hard to put something online right now(cause it will be public and every one will enter)

Я не знаю почему так сложно понять суть проблемы, может на русском проще?
Создается ajaxLink который подгружает CGridView с данными в <div id="ajaxPlace"></div>
, ПРи первом нажатие на ajaxLink все ок, дальше если подгружает пару раз, то к примеру каждое нажатие пагинации уже будет срабатывать более одного раза, в соответсвии с количеством нажатия на ajaxLink который делал replace=>'ajaxPlace'
То же самое и с CButtonColumn с кнопками удаления которые будут спрашивать конфирм теперь десяток раз.

А все оптому что die('click') не работает так как вы предполагаете.

Я выше продемонстрировал как решить проблему,и дал ссылку на ресурс который объесняет что такое die.

now in english:

Create ajaxLink that loades via replace=>ajaxPLace , CGridView into some div with ajaxPlace id.

Do it multiple times, and you will see that events are add up, the pagination send request a lot of times, the delete confirmation alot of times, and also the delet request will be sent a lot of time.

All of this because die('click') not kill the live events outside it's block, it is not a "global killer" so you can remove it, it does nothing...
0

#11 User is offline   samdark 

  • Having fun
  • Yii
  • Group: Yii Dev Team
  • Posts: 3,428
  • Joined: 17-January 09
  • Location:Russia

Posted 13 October 2011 - 05:37 AM

So this happens when you are loading grid itself via Ajax call.
Yii 1.1 Application Development Cookbook

Enjoying Yii? Star us at github: 1.1 and 2.0.
0

#12 User is offline   sidewinder 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 210
  • Joined: 08-July 09
  • Location:Poland

Posted 13 October 2011 - 05:40 AM

View Postdckurushin, on 09 October 2011 - 03:14 AM, said:

die works only in the same block the click event was attached
more about that here
http://www.alfajango...y-live-and-die/

Steve Schwartz@Alfa Jango said:

When using these functions, there is one major shortcoming to the .die() method. You can ONLY use it for the exact element selector for which the .live() function was invoked.


Where did you find information about die working only in the same block click was attached? I checked die() documentation and they mention only exact selector issue.
---------------------------------------------------------------------
"Never memorize what you can look up in books."
Albert Einstein
0

#13 User is offline   dckurushin 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 392
  • Joined: 16-March 11
  • Location:Israel

Posted 13 October 2011 - 06:29 AM

read here http://www.alfajango...y-live-and-die/

I tested it... you cant do die('click') it works, but not like global killer... you can find more in google and stack overflow ... I have the latest jQuery, so that is not a problem...

the only solution to put some hidden or you cant load CGridView via ajax multiple itme
0

#14 User is offline   stereochrome 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 15-August 11

Posted 05 April 2012 - 10:59 AM

any news on this? this is still a problem.
0

#15 User is offline   codesutra 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 596
  • Joined: 15-March 11
  • Location:India

Posted 06 August 2012 - 08:47 AM

View Postdckurushin, on 13 October 2011 - 06:29 AM, said:

read here http://www.alfajango...y-live-and-die/

I tested it... you cant do die('click') it works, but not like global killer... you can find more in google and stack overflow ... I have the latest jQuery, so that is not a problem...

the only solution to put some hidden or you cant load CGridView via ajax multiple itme

Any updates on this issue...Since i am getting the same problem in my app. Which is still not resolved.I am using yii 1.1.10 and dont know why i am getting this error. :(

Anybody can suggest a stable solution for it.

Thank in Advance....

Thanks and regards,
jayant
CodeSutra
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