Welcome Guest, Not a member yet? Register   Sign In
Passing text from rich text editor as iframe
#1

[eluser]tirithen[/eluser]
I'm trying to implement an rich text editor written in javascript to the admin part of my webpage, basicly the rte is an form with text editing buttons and a submit button. The easyest way of getting it into my admin page is by using an iframe but then the problem is, how do I pass the text to the form on the main page that would mabye check some thingd and then submit the text into a database. I guess it's about post or get method but I can't find the info on how to implement it.

Someone that knows of a better/simpler way of doing this?
#2

[eluser]Michael Wales[/eluser]
I'm trying to determine why it would be simpler to place something like this in an iframe? Less code to write elsewhere when you want to reuse the RTE (build a library for it)?

I guess you could always use Javascript... when the iframe loses focus retrieve the value from the RTE textarea and place it within a hidden field on the main page's form - nasty hack though.
#3

[eluser]tirithen[/eluser]
Yes that would be the ideal way to, but I don't think I would be able to code that. I have to learn some more first. I'm still quiet new to CI and PHP...
I have found one RTE in javascript that I have modified a bit and want to simply put into the site to get me going for now.
#4

[eluser]tirithen[/eluser]
But I was thinking, my assumption is that you have to use client side script to make a RTE and that would be javascript. If I then would be using javascript to code the RTE and wanted to build a library, would you have the library to control a javascript file that would be placed outside the system folder or would you include the javascript into the library?
#5

[eluser]Pygon[/eluser]
Typically this would be include outside of your library. This makes it far easier to include an RTE (typically just a <textarea></textarea> with a special class name or the like), in which you place your HTML text, thus the text shows up inside the editor. You'll pretty much be doing the same thing whether it's in your page or in an iframe.

Further, you might want to consider using something like jQuery, Prototype, or other JavaScript framework which would make simple work of submitting the contents via an AJAX request. There is a nice video that shows how to use an AJAX request as part of an autocomplete field, but you can get the idea from this as to how to update your DB.
#6

[eluser]Nick Husher[/eluser]
I agree.

My own personal structural convention for client-executed code is to set up my root directory like this:
Code:
/index.php
/system/... #CI Applciation (server-executed code)
/.htaccess
/src/    #client-executed code
/src/css #css files
/src/js  #javascript files
/src/img #site image files (background images, icons, non-dynamic artwork etc.)
/src/fla #site flash files (for sIFR, usually)
At that point, it becomes quite easy to include those files in my CI views:
Code:
<head>
<base href="path-to-application/" />
<link rel="stylesheet" type="text/css" href="/src/css/screen.css" media="screen" />

...
</head>

Note that your base href can be dynamically generated from your CI config settings. You might want to use more human-friendly directory names; I picked abbreviated ones because I started doing web development entirely on the command line where three-character directory names are sorta-standard. The only reason I keep it up is out of habit.
#7

[eluser]aart-jan[/eluser]
Maybe you could have a look at the Rapyd library, is has a built-in RTE for CI.
#8

[eluser]tirithen[/eluser]
There is an built-in RTE for IC? That's perfect why have I not seen it before, I'll check it out as soon as I get home.

Thanks for all the input, I'm leraning a great deal from this ideas. I did not know of the html tag <base> but that is perfect for including external apps into the CI app. I had problems when I tried to include an RTE that I found that was a number of files with relative URL's inside them, it was a mess trying to get all those URL's to work from an other directory than the controller dir and I did not want to place all those .htm, .js and images inside the controller dir.

Thanks for the tips, I'll look in to Rapyd library later today.




Theme © iAndrew 2016 - Forum software by © MyBB