dhtmlxEditor not allowing input when attached to form

Hi,
I’m using the pro version of DHTMLX suite and am attaching a form to a cell with in a layout and loading the structure for that form via XML file.
This works fine…

The XML file contains however contains an editor item type=“editor” and this causes the editor to display correctly in the form however I cannot add any text to it and the mouse cursor does not change to the ‘I beam’ icon denoting that this is an area that can be typed into.

View:

var newCourse = mainLayout.cells("c").view("New Course"); newCourseAdminForm = newCourse.attachForm("newCourse"); newCourseAdminForm.loadStruct("codebase/xml/forms/newCourse.xml?e=" + new Date().getTime()); var ncToolbar = mainLayout.cells("c").view("New Course").attachToolbar(); ncToolbar.setIconsPath("codebase/imgs/"); ncToolbar.loadXML("./codebase/xml/menus/manageCourses.xml?etc=" + new Date().getTime()); ncToolbar.attachEvent("onClick", function(menuID){ menuAction(menuID); }); newCourseAdminForm.attachEvent("onButtonClick", function(){ processUserForm("New Course",newCourseAdminForm,[menuAction]); }); newCourseAdminForm.attachEvent("onEnter", function(){ processUserForm("New Course",newCourseAdminForm,[menuAction]); });
XML:

<items> <item type="fieldset" label="Create New Course" inputWidth="620" offsetLeft="10"> <item type="input" label="Course Title:" name="courseTitle" value="" maxlength="128" inputWidth="450" required="true" validate="NotEmpty" /> <item type="input" label="Course Code:" name="courseCode" value="" maxlength="32" required="true" validate="NotEmpty" /> <item type="editor" label="Description:" name="courseDescription" value="Hello World!" inputHeight="150" inputWidth="450" required="true" validate="NotEmpty" /> <item type="button" value="Add Course" offsetLeft="288"/> </item> </items>

even if i add a value=“hello world!” to the XML file for the editor that does not show int it. :frowning:

Thank you for your help

Hi
There is no issue locally:
dhtmlx.com/docs/products/dht … ditor.html
Could you create a ticket in support system and provide us completed demo or direct link to rest it?
docs.dhtmlx.com/doku.php?id=othe … leted_demo
Also paste there link to this topic, please.

I managed to sort this problem out.

I had another issue that was also fixed when resolving this issue.

The form i built using loadStruct() had a different number of fields to the data I was passing into the form via load and this caused the issue. It also caused the validate function of the send() method to fail and I think from memory caused d = ‘undefined’ this then dropped out of the method with no exceptions. You may wish to add some exceptions to the dhtmlxForm object as it took nearly a whole day (i’m still a noob) of debugging to find what i had done wrong due to the fact that there were no errors being being thrown despite my attempts to use try catch and console.log()

Thanks for looking into the problem for me and I hope this feed back is of use to you.

Rick

ok Darya I’m having the issue again…
I have created a small demo of the problem for you. I am using an extended trial version of the pro dhtmlx suite for a major assessment project with permission from sales which is due in 1 weeks time.

The version of the dhtmlx.js file is the recompiled one you sent me with the fixes in it to the problem i have previously identified. I have attached it to this post in case it may be the cause.

This issue seems to be when you attach an editor to a form and that form is initialized by an XML file using loadStruct. I also tried to use load to provide data to the form in case that helped. it did not :cry:

[code]

Untitled html, body { width: 100%; height: 100%; margin: 0px; overflow: hidden; } [/code] newSlide_step2.xml File: [code]<?xml version="1.0" encoding="UTF-8"?> [/code] the blank.html file [code] [/code] newSlide2FormData.php file: [code]<?php header("Content-type: text/xml"); $xml = "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n"; $xml .= "\n"; $xml .= " test\n"; $xml .= " poo\n"; $xml .= " 2\n"; $xml .= "\n";
echo $xml;

?>[/code]

I have spent the whole day trying to get this working with no luck…
PLEASE HELP…

Rick

DO NOT ATTACH any pro filen on forum.
ONLY through the support system or by support email.

Wait for answer, please.

very sorry Darya…

Locally it works fine event with your recompilled file


Just make some editings in blank file: you need to call the parent:
onclick=‘parent.mainLayout.cells(“a”).view(“Editor”).setActive();’

I changed the onclick event as suggested and it still does not work.
Tried in IE10, FF21 and Chrome 27.

The editor does show correctly but i cannot click into it and type any text…

Make the next changes:

in ‘blank’:

in ‘index’:
after
newSlide2AdminForm.load(“newSlide2FormData.php?e=” + new Date().getTime());

function setEditorView(){ mainLayout.cells("a").view("Editor").setActive(); newSlide2AdminForm.getEditor("slideContent")._prepareContent(true);

ok that worked… :smiley:

what was the issue? I’ve not seen that in the documentation anywhere.

thank you for your help.

I will have to integrate:-

newSlide2AdminForm.getEditor("slideContent")._prepareContent(true);

into my application as the solution.

I just implimented the code into my project and i get the following error

The actual code that creates the view that i’m having trouble with is

            var newSlide2 = mainLayout.cells("c").view("New Slide Step 2");   
            var newSlide2AdminForm = newSlide2.attachForm("newSlide2");
            newSlide2AdminForm.loadStruct("./codebase/xml/forms/newSlide_step2.xml?e=" + new Date().getTime());
            //newSlide2AdminForm.load("./data/slides/newSlide2FormData.php?e=" + new Date().getTime());  // get data to populate form
            
            newSlide2AdminForm.getEditor("slideContent")._prepareContent(true);
            
            var ns2Toolbar = mainLayout.cells("c").view("New Slide Step 2").attachToolbar();
            ns2Toolbar.setIconsPath("codebase/imgs/");
            ns2Toolbar.loadXML("./codebase/xml/menus/manageSlides.xml?etc=" + new Date().getTime());        
            ns2Toolbar.attachEvent("onClick", function(menuID){
                menuAction(menuID);
            });
            newSlide2AdminForm.attachEvent("onButtonClick", function(){
                processForm("New Slide Step 2",newSlide2AdminForm,[menuAction]);
            });

the XML is exactly the same as in the previous example.

please advice…
Rick

I have a solution that works although not sure that it’s the cleanest solution.

I have added the following event register to the form.

newSlide2AdminForm.attachEvent("onEditorAccess", function(name, type, ev, editor, form){ newSlide2AdminForm.getEditor("slideContent")._prepareContent(true); });

this allows the application to load and function without the error I previously posted and then only exicutes the ‘prepareContent’ when the editor is clicked in.

please advice if there is a better/cleaner solution or if there will be modifications made to the dhtmlx library for this.

Rick

nope thats still not quite right… now when i type it’s only typing text from the left almost like inserting only (it pushes the text along to the right) and i cannot select any of the text.

I’ll have to leave the final solution up to the experts…

Awaiting your reply and solution.

Rick

ok last try…

if i do a test for the event type as focus it seems to work correctly

newSlide2AdminForm.attachEvent("onEditorAccess", function(name, type, ev, editor, form){
    if(type === 'focus'){
        newSlide2AdminForm.getEditor("slideContent")._prepareContent(true);
    }
});

again please advice if there is a better solution.

Rick

Call this not for editorAccess. You need to call it after editor’s view comes active

Sorry Darya, I don’t quite understand can you provide a code example?

I’ve wrote that you need to place line
newSlide2AdminForm.getEditor(“slideContent”)._prepareContent(true);
after your view with editor come active
mainLayout.cells(“a”).view(“Editor”).setActive();

thank you for all your help…

The issue form me with integrating this solution was that I have a separate function that handles all the views states. I have now modified that function to check for this particular view and than execute the solution after that view is made active.

All works fine now. :slight_smile: :smiley:

Is is common that as developers we will need to access private methods of the library ?
Will this be addressed in future releases ?

thank you again for your help.
Rick

Such nuances happen. We try to add such features from time to time. And this will be added in the following versions possibly.