Running javascript in view after block edit
Permalink
Hi all,
Reference:
http://www.concrete5.org/community/forums/customizing_c5/5-4-block-...
I hate to move a question to a different thread, but this is my last issue before I can launch a block both at work and on the marketplace, so apologies in advance for the double posting.
Anyway, I have a block that uses javascript in the view.php file. Code works, everything is tested, etc. The issue I have is when someone goes to edit the block, apparently the javascript in the view block doesn't run after the edit -- because of this, since most of the visual elements are in javascript, it looks like the block disappears completely after the edit is complete. The solution is easy ... do a page refresh on the browser and everything shows up fine. This makes it good enough for my use and my department's use, but I can release this to the wider audience in this condition.
In the referenced thread, the original poster mentions they found a workaround for this issue, but didn't give details on how the workaround was implemented. Anyone else know how to fix/kluge this issue? Thanks!
D
Reference:
http://www.concrete5.org/community/forums/customizing_c5/5-4-block-...
I hate to move a question to a different thread, but this is my last issue before I can launch a block both at work and on the marketplace, so apologies in advance for the double posting.
Anyway, I have a block that uses javascript in the view.php file. Code works, everything is tested, etc. The issue I have is when someone goes to edit the block, apparently the javascript in the view block doesn't run after the edit -- because of this, since most of the visual elements are in javascript, it looks like the block disappears completely after the edit is complete. The solution is easy ... do a page refresh on the browser and everything shows up fine. This makes it good enough for my use and my department's use, but I can release this to the wider audience in this condition.
In the referenced thread, the original poster mentions they found a workaround for this issue, but didn't give details on how the workaround was implemented. Anyone else know how to fix/kluge this issue? Thanks!
D
Shameless self bump. Last attempt I promise...
It seems like when you open the edit box after a previous edit, the javascript is not reloaded. I might be wrong.
My problem was using tinyMCE in the edit box. For this to work for a reopen of the box, I needed to remove the instance of the editor and initialize it everytime the edit box was shown again.
This wasn't helping you very much I guess, but maybe I put you in the right direction?
My problem was using tinyMCE in the edit box. For this to work for a reopen of the box, I needed to remove the instance of the editor and initialize it everytime the edit box was shown again.
This wasn't helping you very much I guess, but maybe I put you in the right direction?
Thanks for taking the time to answer!
I finally found a fix to the issue, although its not the ideal solution. Upon certain conditions being met (aka updates via edit), the view instructs the browser to do a refresh, thus showing the complete block with all the updates after the add/edit/etc is complete.
Since I'm dealing with third party code, I can't really rewrite the javascript portion of my view (since their code is in js), and since I want my finished code to be downloadable on the marketplace, I can't change any settings in Concrete itself (aka automatically do block refreshes after any update). So, I'm not thrilled in doing a forced page refresh; on the other hand, it gets the job done and solves all my view problems, without having to get a job at the third party and surreptitiously changing the code to be what I want :)
So looks like we had the same ideas on similar but not quite the same issues....
I finally found a fix to the issue, although its not the ideal solution. Upon certain conditions being met (aka updates via edit), the view instructs the browser to do a refresh, thus showing the complete block with all the updates after the add/edit/etc is complete.
Since I'm dealing with third party code, I can't really rewrite the javascript portion of my view (since their code is in js), and since I want my finished code to be downloadable on the marketplace, I can't change any settings in Concrete itself (aka automatically do block refreshes after any update). So, I'm not thrilled in doing a forced page refresh; on the other hand, it gets the job done and solves all my view problems, without having to get a job at the third party and surreptitiously changing the code to be what I want :)
So looks like we had the same ideas on similar but not quite the same issues....