Saving changes in ckeditor - javascript

I'm using CKEditor in a website and I want to use it as editor of the page itself. So the user goes to the page, modifies what he wants in the ckeditor textarea(s) and then he clicks 'save' or 'submit' and the page is modified (that page would be protected by a login, so only certain users could modify).
Problem is I have no idea how to save the content of ckeditor in that same textarea that was modified, I tried looking around but everyone wanted to save data in a DB or send it to some other page.
I found 2 plugins that implement some save function but again, I don't know if I can use those to do what I want. (Save plugin, Inline save.
Hope you understood what I'm asking, thanks in advance.

Related

How do I make specific inputs go into another .html file in the project?

I wanted to make specific inputs go into another part of a site (e.g. https://myexamplesite.com/anotherpartofit.html)
And also make those specific inputs be the ones that someone saved it in.
An example of what I think would work is: Get value from input 1 from /apartofit.html and put it in input 2 at /anotherpartofit.html and make it non-editable
If it needs to use a database, I would prefer if you could help me with firebase (Google's Database). But in my knowlege, it probably needs to use javascript, so I'll be tagging it, if it doesn't, let me know!
in visual studio or notepad or every offline web creating spaces you can't but if you buy a domain or simple , online site , you have to crate a page and get the link of that page then open another page create a button set the button's href to link of pervious page finally hit the button !

Dynamically created input element not shown after user hit Back button

I create dynamic input elements with this code:
<div id="add">Add row</div>
<script>
$(document).on('click', '#add', function() {
var number = $('div[id^="row_"]').length + 1;
$('#add').before('<div id="row_'+number+'"><label for="answer_'+number+'">Question #'+number+'</label> <input id="answer_'+number+'" name="answer_'+number+'" type="text"></div>');
});
</script>
If I send the form and hit the BACK button all other input elements show the text of the user, except the dynamically created input fields. The fields itself don't show up.
I tried to put the user's text into a hidden field via jQuery but it is also disappeared after the BACK button.
How can I show the previous state of the whole form to the user after they hit the BACK button?
SOLUTION:
If I put the user's text into a type="text" element with style="display:none", I have the text after the BACK button and I can recreate the dynamic fields with the user's text.
Thanks everyone for the suggestions, hopefully this will help others who come across this problem.
Upon POSTing the form, the browser navigates to the location (url) of your <form>'s action. When you then go back, it will reload your page and the state of all scripts is reset because the page reloaded.
If you want to keep that state, you need to send the form via AJAX. You can do that with jQuery as well (see here). Then you'll not even need to hit the back button.
I think maybe I fully understand your problem now after chatting, I hope, anyway! --
Browser Code Cache
When you download a page in Chrome or your browser, it is stored in your local browser cache. But it stores the commands, not the state, of the page. So, when you go back, the HTML is rerendered per the HTML and CSS commands, and the JS is re-executed. I found some information from v8.com, the official dev blog for Chrome...
When the JS file is requested a second time (i.e. a warm run), Chrome takes the file from the browser cache and once again gives it to V8 to compile. This time, however, the compiled code is serialized, and is attached to the cached script file as metadata.
So, you see, it recompiles and reruns the JavaScript when you hit the back button, but it does not restore the previous elements generated from the last JavaScript running, or the events that the user committed to triggered that state.
Source: V8.com: Code caching for JavaScript developers
Back-Forward Cache (BFCache)/Browser Form Cache
Don't mix this up with cached form data, which is completely different. Chrome will cache your old form data with the back button automatically, but that is not part of the code caching feature. Check out this similar question for that problem: Clear all fields in a form upon going back with browser back button
Google 2019, Feb Update: This appears to be something that should be fixed at some time within the near future. Source: Exploring a back/forward cache for Chrome.
Here is a solution:
I tried to put the user's text into a type="hidden" element via jQuery, and it has been lost, after the BACK button, however if I put the answer into a type="text" element with style="display:none", I have the user's text after the BACK button and I can recreate the dynamic fields with the user's text.
Thanks everyone for the suggestions, hopefully this will help others who come across this problem.

Automatically refresh SharePoint site when item is added to a Form Library

I have a question about automatically refreshing a SharePoint form library any time an item is added to it. We have a business team within our company where any individual on the team can fill out a particular InfoPath form. Once that form is filled out and submitted, it is saved to the aforementioned SharePoint form library.
When any user submits a form like this, the other users like to know that it has happened and they almost always have their browsers open and pointed to this particular SharePoint form library. These form submissions and the data they contain are somewhat time-critical, so it's an important way for everyone on the team to be up-to-date about the submitted information.
Does anyone know if such a workflow is possible in InfoPath? I've Googled this issue already and I've found a lot of helpful advice about redirecting to the same page using the SPUtility class's functionality (which does seem to work), but I want to refresh/redirect the entire page, not just the pop-up window for which the SPUtility class is apparently responsible. I've also seen some results suggest using a Content Editor web part containing some JavaScript for refreshing the page and then accessing that Content Editor via a workflow or event receiver. Does anyone have any experience solving an issue like this or have some ideas? I'm not looking for anyone to write the solution for me - I just need a push in the right direction from someone that's more experienced with SharePoint.
Thanks!
I would suggest a bit of JavaScript that periodically redirects the page to itself. If you wanted to get flashy, you could use the Client Object Model to query the list for the last modified date of the last modified item. If that changes, refresh, or you could use the Notifications API to show a nice 'Notification', perhaps with a refresh button that reloads the page?

Creating a preview page in CakePHP

I'm building a site in CakePHP, and I'd like to give a 'Preview' option for pages as they're being added or edited.
In the 'Add Page' view, for instance, I have the usual form which the user uses to create their page. There is a 'Save' button, to save the data. Next to that, I'd like to have a 'Preview' button, which opens the page in a new window.
So, either I need the controller to open a new window (and I don't think this is possible), or it needs to be a link (targetting a new window) instead of a button - but in that case, how do I POST the data so that it can be shown? Do I need to use ajax or something? I'm a total newbie in ajax, but I do have a reasonable grasp of javascript.
Thanks for any help!
If the data that you are previewing is already saved on your database, then you can have an action in your controller (maybe preview()) action that references the saved data and loads the preview. And then to use it, you can just use a regular link that targets a new page and opens it there.
This would require saving the data the user is typing to your server every few seconds, though.
If you want to use the data that is still on the page, then you can use a JavaScript function to load a lightbox and populate the contents of that lightbox with data from the fields that the user is working on. You can probably use fancybox for that.

ckeditor: how to wire up menu buttons?

I have ckeditor embedded into one of my pages....but I don't know how to wire up certain buttons in ckeditor to perform specific actions. Most importantly, how do I tell it when the save button is clicked to save the document?
Dave--
The beauty of the save button in CKEditor is that it is setup default to submit the form that it's in. In my company's case, I bolted in CKEditor expecting to have to disable the save button because the larger form already had a save button...but it turns out that it worked right out of the box. Get the system installed, tested, and hit save...see what happens.
You can control the output of buttons in the Config.js file. If a particular button is not to your liking, you can use javascript to define actions or create new buttons there as well. There are fairly good tutorials on this at http://docs.cksource.com/

Categories