enyo.kind recreate, after destroying

Hi all,

I've grep'ed the entire Internet for the proper methods, and have come to the conclusion that I maybe using Enyo in a way in which it was not designed to be used, maybe?

The definition of may project; Is to allow the web server application to micromanage to client DOM. I chose Enyo because I had initially intended to use JSON for the format to send/receive DOM objects between the server and the browser. Enyo seemed to be right in-line with doing this, has it renders the JSON as is from the server using .renderInto(), right?

When I receive a new enyo.Kind from the server (via WebSocket, not a http response), I first tried the following:

Keep in mind my javascript is weak at best:
case "initform" :
	a.destroyComponents();
	eval(instruction.substring(10, str.length - 3));
	a = new App().renderInto(document.body);
	break;
If I replaced the eval() with a valid enyo.kind(....), then the rest of the code does what I need. I have verified that the “instruction.substring(10, str.length – 3);” does contain a valid enyo.kind, and so, I thought I'd bounce this off you guys to see if maybe I should be using a different method. Maybe something other than eval() Enyo.eval()?

Any and All help is very much appreciated.

Comments

  • If you have a kind in JSON format already, you can use the createComponent() method to create an instance of the kind.

    If you are trying to make new kinds, via enyo.kind(), you may want to look at the remoteControl kind a user here has made: http://blog.technisode.com/post/41331812157/enyo-remotecontrol
  • in your example, you'd need to first convert your string to a JavaScript object. Assuming it's valid JSON, pass the string to enyo.json.parse and it will convert it. Then you can pass it to enyo.kind if desired. If all you're doing is rendering some DOM nodes, I'd suggest either returning the HTML string from the server (fastest for the client) or creating an instance of enyo.Control passing the object to the constructor and render that object.
Sign In or Register to comment.