|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
cftextarea setValue() and jquery dialog
We have a jquery dialog that contains a cfform with the CF rich textScott Brady 06/14/10 10:26 P On 15/06/2010 10:25, Scott Brady wrote:Azadi Saryev 06/15/10 12:10 A But the text area exists on the page already. The empty cftextarea would beScott Brady 06/15/10 10:15 A the <textarea> element exists on your page, but its ckeditor (richtext)Azadi Saryev 06/15/10 11:06 A Ok, I'm still having issues following this.Scott Brady 06/15/10 11:50 A it was actually me who was misunderstanding things!Azadi Saryev 06/15/10 12:44 P Hmmm .... in that case, I may just go with it. Our dev environments areScott Brady 06/15/10 01:00 P yeah, since cf9 uses newer version of ckeditor, some things have changed...Azadi Saryev 06/15/10 02:03 P actually, in your case (cf9 + richtext textarea inside jquery dialog)Azadi Saryev 06/15/10 02:22 P Thanks! I'll try that.Scott Brady 06/15/10 02:23 P ...and the winner is (works in both cf8 and cf9):Azadi Saryev 06/15/10 02:29 P nope, the winner is this list and the cf community at large by yourVictor Moore 06/15/10 03:26 P Awesome! I'll try that later today. Thanks for all the help.Scott Brady 06/16/10 07:00 A Well, "later today" became "a month and a half later". Got pulled off intoScott Brady 07/31/10 02:07 P Actually, I made a little progress. I realied #f1 should be my form ID, soScott Brady 07/31/10 02:17 P Any ideas on this? Or, should I look at getting rid of the built-in CKScott Brady 08/04/10 10:25 A 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/ 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 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 ----- 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 ----- 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 ----- 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 ----- 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 ----- 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 ----- 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 ----- 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/ ...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 ----- 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 ----- 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/ 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 ----- 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 ----- 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/
|
September 05, 2010
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||