Issue
In CakePHP 3, I am having troubles with "breaks" in ajax requests. The specific page is reload (if needed) by ajax requests, called every 5 seconds. The page is correctly refreshed.
The problem appears if a logged user (to his own account) clicks a "delete" button on a selected element. If the button uses javascript "onclick confirm" and the user waits more than 5 seconds before he clicks "OK" as a confirmation, he is completely logged out from his account.
echo $this->Html->link($this->Html->image("../img/btn/btn_usun.png"),
array('controller'=>'offers','action'=>'delete/'.$this->Encrypt->encryptID($id_rekordu)),
array('escape'=>false,'onclick'=>'return confirm(\''.__d('offer','Czy usunac oferte',true).'\');',
'title'=>__d('default','Usun',true))
);
If the button does not have the "onclick confirm" - the element is deleted, page is refreshed and it works correctly
echo $this->Html->link($this->Html->image("../img/btn/btn_usun.png"),
array('controller'=>'offers','action'=>'delete/'.$this->Encrypt->encryptID($id_rekordu))
);
What can be a solution to use both the ajax refresh at the background, and "onclick confirm" before deleting, and do not logout the user if he is slow to click "OK" in the confirmation?
Solution
Seem like you need to intersect while waiting before user click OK on confirmation popup. I believe that default jquery confirmation may not intersect while popup showing unless you use another library. I would like to recommend the following library. Basically if popup is showing on screen, you can intersect like clearInterval
or reset interval after you click confirm. Hope this help for you.
https://craftpip.github.io/jquery-confirm/#callbacks
Answered By - 502_Geek
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.