We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Initialize on data attributes

Thread ID:





124865 Jul 5,2016 10:10 AM UTC Jul 18,2016 05:10 AM UTC JavaScript 6
Tags: General
Asked On July 5, 2016 10:10 AM UTC

I prefer to initialize controls based on html, however this is not working if a page gets loaded via ajax. If I create the control with javascript after the ajax page load the component renders with all the default values instead of the specified values from the data attributes.

Demo, new area gets prepended before the editor, waits are purely to demonstrate the effects

Replied On July 5, 2016 10:22 AM UTC

PS: The rte is merely used as an example. The question is : how can I instantiate dynamically loaded controls based on data attributes?

Dhivyalakshmi Thirumurugan [Syncfusion]
Replied On July 7, 2016 01:02 PM UTC

Hi Wouter, 
Thanks for contacting Syncfusion support. 
We have analyzed your sample and you have used jQuery clone() method. The clone method only clones the DOM element, so we cannot expect it copies the model value of RTE(properties). For setting the model values, first we need to take that instance of the corresponding RTE and save that model values in variable, then should pass it to the RTE rendering. Please find the code below.
setTimeout(function () { 
// Creates the RTE 

var obj=$("#CorrectLoaded").data("ejRTE"); 
var rte=obj.model; 
var rteObj = $("#IncorrectLoaded").data("ejRTE"); 

rteObj.setHtml($("#IncorrectLoaded").val() + 
              "<br />RTE is created, but with de defaults :( \n<br />RTE Instance is: <br /><pre>" + 
              JSON.stringify(rteObj, function (key, val) { 
                             if (val != null && typeof val == "object") { 
                                           if (seen.indexOf(val) >= 0) { 
                             return val; 

}, 9000); 

We have prepared the sample as per your requirement and please find the sample below.
Sample Link: http://jsplayground.syncfusion.com/c1uiv3cf
If we have misunderstood your query, then please get back us with more details, so that we will help you better.
Please let us know if you have any queries. 

Replied On July 13, 2016 12:48 PM UTC

The clone method was used as a substitute for ajax loading. What I meant was that the html is not there at page load. Here is a simple example: http://jsplayground.syncfusion.com/ylls4te2
I know that adding the data-role beforehand fixes the problem, but I want to instantiate manually but still use the configuration via the data attributes.

Dhivyalakshmi Thirumurugan [Syncfusion]
Replied On July 14, 2016 06:42 AM UTC

Hi Wouter, 
Thanks for the update. 
For instantiating the RTE control manually. Please check the below code.   
<div id="renderDiv">   
              <textarea id="FollowUp"      
                data-ej-toolslist="[&quot;lists&quot;,&quot;clipboard&quot;,&quot;doAction&quot;,&quot;clear&quot;,&quot;links&quot;]" >   
   <script type="text/javascript" class="jsScript">   
    $(function() {           
        $("#FollowUp").attr("data-role", "ejrte");   
In the above code, we have created the wrapper around the RTE and passed that wrapper id to ej.widget.init() function. Because ej.widget.init(“#rendrDiv”) is used to initiate the control which is given within that wrapper.   
We have prepared the sample for your reference. Please check the sample link below.   
Please let us know if you have any queries.  


Replied On July 14, 2016 07:49 AM UTC

Thanks! Thats what I was after.

Dhivyalakshmi Thirumurugan [Syncfusion]
Replied On July 18, 2016 05:10 AM UTC

Hi Wouter,    
Thanks for the update.    
We are glad to hear that your issue has been resolved. Please get back to us if you need any further assistance.    


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon