|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
cftextarea setValue() and jquery dialog
Author: Scott Brady
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#335979
Any ideas on this? Or, should I look at getting rid of the built-in CK
editor and implementing the CK editor myself?
Scott
----- Excess quoted text cut - see Original Post for more -----
-----------------------------------------
Scott Brady
http://www.scottbrady.net/
Author: Scott Brady
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#335915
Actually, I made a little progress. I realied #f1 should be my form ID, so
I changed that, and now ta.attr('id') does return the right ID. But, now
I'm getting this error:
"this.EditingArea is undefined"
caused by this line:
ColdFusion.RichText.setValue(ta.attr('id'),responseData.socialEventDescription);
Scott
On Tue, Jun 15, 2010 at 12:28 PM, Azadi Saryev
<azadi.saryev@gmail.com>wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Scott Brady
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#335914
Well, "later today" became "a month and a half later". Got pulled off into
more urgent issues, so I'm only just now getting back to this.
I've tried what you've suggested and either nothing happens or I get the
same issue.
If I alert ta.attr('id'), I get undefined. (also, if I alert ta.val(), I
also get undefined).
So, I think it's close, but the setting of ta may be off.
I'll try to keep playing with that, but I'm open to suggestions.
And, I really do appreciate the help.
Scott
On Tue, Jun 15, 2010 at 12:28 PM, Azadi Saryev
<azadi.saryev@gmail.com>wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Scott Brady
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#334591
Awesome! I'll try that later today. Thanks for all the help.
Scott
On Tue, Jun 15, 2010 at 12:28 PM, Azadi Saryev
<azadi.saryev@gmail.com>wrote:
----- Excess quoted text cut - see Original Post for more -----
--
-----------------------------------------
Scott Brady
http://www.scottbrady.net/
Author: Victor Moore
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#334586
nope, the winner is this list and the cf community at large by your
great contribution.
Thank you
----- Excess quoted text cut - see Original Post for more -----
Author: Azadi Saryev
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#334585
...and the winner is (works in both cf8 and cf9):
var ta = $("#f1 textarea[name='socialEventDescription']");
ColdFusion.RichText.setValue(ta.attr('id'),
responseData.socialEventDescription);
ta.val(responseData.socialEventDescription);
$("#dialog").dialog("open");
hth
Azadi
On 16/06/2010 02:22, Scott Brady wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Scott Brady
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#334584
Thanks! I'll try that.
On Tue, Jun 15, 2010 at 12:02 PM, Azadi Saryev
<azadi.saryev@gmail.com>wrote:
----- Excess quoted text cut - see Original Post for more -----
--
-----------------------------------------
Scott Brady
http://www.scottbrady.net/
Author: Azadi Saryev
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#334583
actually, in your case (cf9 + richtext textarea inside jquery dialog)
it is as easy as setting the value of actual textarea element using
jquery before the dialog is opened!
$("textarea[name='socialEventDescription']").val(responseData.socialEventDescription);
$("#dialog").dialog("open");
since cf9 re-draws the richtext textarea, it will show the new value in it.
however, this will NOT work in cf8...
Azadi
On 16/06/2010 02:02, Azadi Saryev wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Azadi Saryev
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#334582
yeah, since cf9 uses newer version of ckeditor, some things have changed...
i have seen some rather weird stuff in my tests now with cf9.
i guess it has something to do with the textarea being initially hidden,
and then displayed when the dialog is displayed. this must be causing
some event chain to fire, which happens to make the ckeditor instance
associated with the textarea temporarily unavailable. i _think_ that
maybe the textarea instance is re-drawn (or maybe even drawn for the
first time) only after the dialog is visible (you may have noticed that
fckstyles.xml file is requested only after the dialog is shown), and
that causes the instance to not be defined for a moment.
in any case - if you are still interested - firing the setValue() with a
delay of 1000 ms after the dialog is opened seems to solve the problem
in cf9:
var ta = ColdFusion.RichText.getEditorObject('socialEventDescription');
if (ta) {
ColdFusion.RichText.setValue(ta.Name, str);
} else {
setTimeout(function(){ColdFusion.RichText.setValue(ColdFusion.RichText.getEditorObject('socialEventDescription').Name,
responseData.socialEventDescription);}, 1000);
}
Azadi
On 16/06/2010 00:59, Scott Brady wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Scott Brady
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#334580
Hmmm .... in that case, I may just go with it. Our dev environments are
CF9, but production is CF8.
It's on an admin page, so I guess I'll just see what happens and make sure
it works.
Thanks!
Scott
On Tue, Jun 15, 2010 at 10:43 AM, Azadi Saryev
<azadi.saryev@gmail.com>wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Azadi Saryev
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#334579
it was actually me who was misunderstanding things!
i have misread your question and assumed that you were loading an
external page which contained richtext textarea into a dialog...
not that i see what exactly you are doing, i have run some tests, and,
as you said, in cf9 the textarea does not get the new value...
cf8 does not have this problem and works correctly, though...
i will play with it some more and post here.
Azadi
On 15/06/2010 23:49, Scott Brady wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Scott Brady
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#334577
Ok, I'm still having issues following this.
Your suggestion is to run the function when the page loads (ajaxonload).
But, the problem occurs long after the page loads (I can wait 5 minutes
after the page is done loading to try it, and I still get the issue). And,
putting in an onload handler (either with CF's ajaxonload or using jQuery to
append the handler) has it run when the page has loaded -- before I've
clicked the "edit" button that does the ajax request to get the form's
values.
Maybe I'm not explaining it well enough.
The dialog that contains the form is part of the initial page load (i.e.,
it's a hidden div that, upon the document being loaded, is converted into a
jquery dialog. Why would that affect when the ckeditor instance is ready or
not? Even if I wait until the dialog is displayed before populating the
fields, it throws the error, so it's not just because the dialog is hidden
when I try to populate the field.
Alternatively, maybe I don't understand what causes the ckeditor to be
"ready".
Scott
On Tue, Jun 15, 2010 at 9:05 AM, Azadi Saryev
<azadi.saryev@gmail.com>wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Azadi Saryev
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#334575
the <textarea> element exists on your page, but its ckeditor (richtext)
'incarnation' does not.
thus calling ColdFusion.RichText.setValue() at this stage does not
produce any results - because it uses ckeditor-specific javascript
functions to populate the ckeditor instance of the textarea (which is
actually an ifame, iirc) with content, not the actual <textarea> element.
Azadi
On 15/06/2010 22:14, Scott Brady wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Scott Brady
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#334571
But the text area exists on the page already. The empty cftextarea would be
available by the time the page loads (and the div isn't made a "dialog"
until after the page loads). The whole form exists when the page loads.
The ajax is just to get data for populating the form field values
themselves.
So, I don't think that's the issue, unless I'm misunderstanding you.
Scott
On Mon, Jun 14, 2010 at 10:09 PM, Azadi Saryev
<azadi.saryev@gmail.com>wrote:
----- Excess quoted text cut - see Original Post for more -----
Author: Azadi Saryev
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#334565
On 15/06/2010 10:25, Scott Brady wrote:
> The success function then populates the form (including the text area)
i assume you are talking about $.ajax() [or similar] jquery success
callback?
that one will fire before the cf's richtext area is fully ready, thus
your error.
what you can do, is move the success callback into a separate named
function (if you have it defined in-line in success: property of
$.ajax()), and then call it using ajaxonload() cf function by putting
<cfset ajaxonload('function-name-here')>
as the last line before the closing </body> tag in your page that loads
inside dialog.
another option is to create a 'listener' that checks if cf richtext area
is ready for use, and only then fire your function that populates the
form. i don;t have code for this as i have never done it this way, but i
think it can be done with setInterval() ...
Azadi
Author: Scott Brady
Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:61503#334559
We have a jquery dialog that contains a cfform with the CF rich text
editor. We're trying to populate it with theColdFusion.RichText.setValue(()
function, but we keep getting an error.
I've verified we're calling the setValue() function properly, and if I make
the div that contains the form not be a dialog, it works just fine.
Does anyone know of any issues with the rich text area and jquery dialogs?
(I don't see why it would matter -- the form field exists in the source code
regardless).
Here's the basic flow:
1) A user clicks "edit"
2) That calls a function that opens the dialog (with a "loading ..." message
displayed) and calls an ajax request to load data for the form
3) The success function then populates the form (including the text area)
and removes the "loading..." message and displays the form
However, this line in step 3:
ColdFusion.RichText.setValue(document.forms['socialEventForm'].elements['socialEventDescription'].id,responseData.socialEventDescription);
results in a JS error:
_38c is undefined
/CFIDE/scripts/ajax/package/cfrichtexteditor.js
Line 141
Thanks!
Scott
--
-----------------------------------------
Scott Brady
http://www.scottbrady.net/
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||