attempting to assemble some angularjs features using haxe (js target)

33 views
Skip to first unread message

Chris Anderson

unread,
Jan 2, 2014, 10:21:59 AM1/2/14
to haxe...@googlegroups.com
have been trying to prove a concept to my dev team and sell them on haxe.  i'm using haxe template system, andy's jQueryExtern, and bindx (searched everywhere for haxe data binding lib and just recently seen a post about bindx here) to create a worklow similar to angularjs.  was hoping to create a way to bind changes to a model and update a template (eventually hoping for 2 way binding if possible).  if there are libs similar that already exist let me know.

let's say I have some html input with a custom attribute ex:

<input type="text" class="form-control" hx-model="v.a">

how do i get this working using Reflect (or whatever is best):

var modelTest = new js.JQuery('[hx-model]');

var tempFields = Reflect.fields(modelTest.attr('hx-model'));


just being lazy for now (wouldn't mind a effective way to grab nested props for N levels of depth):
var test = Reflect.field(modelTest.attr('hx-model'), tempFields[0]);
var test2 = Reflect.field(modelTest.attr('hx-model'), tempFields[2]);

if(test != null && test2 != null)
{
  trace('found object: ' + test + ' & ' + test2);

  //here i'd like to drop use of v.a and use test & test2 for example
  v.a.bindx(function (from:String, to:String) { trace('v.a changed from:$from to:$to'); TemplateBuilder.updateTemplate(_template, resourceTest, {testString:v.a, testDataObject:testDataObject, testSelectData:_testSelectData}); } );
}
else
{
  throw 'The dom references an object: ' + modelTest.attr('hx-model') + ' but the object wasn\'t found in this class.';
}


appreciate the help guys.
Reply all
Reply to author
Forward
0 new messages