Corrupted data in Ace Editor when using browser 'back' button in single page app - ace-editor

I'm using Ace Editor in a Rails app with TurboLinks. The editor is initialized each time a page is loaded (including when a page is loaded via the browser 'back' button):
$(document).on('turbolinks:load', function () {
var editor = ace.edit("editor");
});
When clicking a link to another page in the application, and then clicking the browser 'back' button, the editor field is corrupted. For example, if the data in the editor is:
toto
tata
The data (displayed in the textarea of the editor) after going to another page an coming back becomes:
12tototataXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
How to prevent this from happening in my application?

My workaround was the following (executed at each turbolinks:load event, including when user uses 'back' button):
remove the previous editor div (exists only when using 'back' button), with something like $('#editor').remove()
load the content from a hidden div that is never edited
add a new div for the editor, with the content to edit (something like $('#foo').after(${content})
initialize the editor with ace.edit("editor");

Related

CKEditor 3.6.1: Load editor on event

I create a page with multiple tabs.
On one of my tabs I want to use CKeditor on a textarea, so when I display my table I call:
editor = CKEDITOR.replace('MyTextArea', MyOptions );
I have the UI of the editor but when I click on the text area nothing append, I can't edit it. The solution for access to the text area is to use "tab" for accessing this field.
I try to put a default value and I can edit if I click on the text but if I click elsewhere in the area I cannot edit.
I have this problem for IE10 and I need it works on it. It's working on Chrome and Firefox. I use CKEditor 3.6.1 and I cannot upgrade it.
Thanks
The problem was the z-index of the container of my textarea, I change it and it works.

Telerik RadWindow to replace existing window

How can I open a telerik:RadWindow so that it replaces the existing window (parent)? I do not want the window as a modal.
If you are opening a RadWindow from within a RadWindow read this: http://www.telerik.com/help/aspnet-ajax/window-programming-opening-from-within-dialog.html.
If your RadWindows use their ContentTemplate it should not be needed and they should be able to move in the entire browser.
If they are already in an iframe (e.g., in a splitter pane, pageview or some other layout you have) the same approach from getting the main window (usually via window.top) will do the trick.
If you do not want an HTML popup you will need to use browser popups. a RadWindow is merely HTML + CSS + JS so it cannot be equivalent to a real browser window.
If you want certain pages to open in the main page when initially opened in a RadWindow look into these articles:
- http://www.telerik.com/help/aspnet-ajax/window-application-alert-for-entire-page.html
- http://www.telerik.com/help/aspnet-ajax/window-application-is-page-in-radwindow.html
or generally into frame buster scripts/tricks.

N2CMS: how to add popup conent

I have a news-type website that I am looking to create using N2CMS, but besides the regular operations (being able to see a calendar, viewing lists of news, viewing news details etc.), part of the content in the website is displayed in "modal" popups (similar to the ModalPopupExtender from the AjaxToolkit) inside the page (for example if you click Login, a popup panel appears with the login controls).
My question is: is there a way of adding a handler for a link, and displaying a "modal" popup when the link is clicked? If so, can this be done from the template GUI editor (and how)?
Thank you
N2CMS doesn't have any built-in handlers to create modal pop-ups for links. However, N2CMS does ship with the Jquery JavaScript library. My suggestion would be to use JavaScript in your site template to select and format the desired links with modal dialogs -- but that can't be done from the GUI editor, you'd need to do it in the template code directly.

Joomla 1.5 system messages in modal window?

I have made a link, that gives me Joomla's registration edit form into a modal window. Everything is okay with this but, when user click on save button, loads the whole homepage in to modal window with a message that says everything saved. How can I make it just load the system message in to modal window and not the whole home page?
set tmpl=component & format=raw in the controller before calling for the template. Your system msgs div should be inside the component to be shown.

How can I make the jquery ui dialog opened even after page reload

I have a webapp that store a layout,
And on its edit mode the user should click on the layout option inside a jquery ui dialog.
After the user choose the template that he/she want, the page will automatically reload.
I want the jquery-ui keep open even after the page was reloaded...
Hope it makes sense.
Hoping for your replys.
King Pangilinan
I guess your whole page is being reloaded? If so you can't keep the dialog open but re-open it when your dom has been loaded. To do so you can do:
$(document).ready(function() {
$("dialog_selector").dialog('open');
});
That just opens it. Now if you want to do it on a page reload you would have to embed this javascript code in some conditional ERB-code (if you're using ERB) or similar which meets your conditions...
Hope it's clear what I mean.

Resources