Sha256: 899238d2428fb4081333f3f5b2615060802688839e27ea9d8a2637c00e7e10dd

Contents?: true

Size: 735 Bytes

Versions: 7

Compression:

Stored size: 735 Bytes

Contents

import jQuery.*;

class RailsViewComponent{
  public var callbacks = new Map<String, Dynamic->Dynamic->Dynamic->Void>();
  public function addCallback(method:String, fun:Dynamic->Dynamic->Dynamic->Void){
    this.callbacks.set(method, fun);
  }
  private var componentName : String;
  public function new(name:String){
    this.componentName = name;
  }
  public function sendRequest(method:String, params){
    JQueryStatic.post(
        "/rails_view_component/"+ this.componentName +"/"+ method,
        params,
        function(data, status, xhr){
          var func = this.callbacks.get(method);
          if(func != null){ func(data, status, xhr); }
        }).fail(function(e){
          trace("ERROR:"+e);
        }); 
  }
}



Version data entries

7 entries across 5 versions & 1 rubygems

Version Path
rails_view_component-0.0.5 lib/generators/rails_view_component/templates/RailsViewComponent.hx
rails_view_component-0.0.5 lib/rails_view_component/haxe/RailsViewComponent.hx
rails_view_component-0.0.4 lib/generators/rails_view_component/templates/RailsViewComponent.hx
rails_view_component-0.0.4 lib/rails_view_component/haxe/RailsViewComponent.hx
rails_view_component-0.0.3 lib/rails_view_component/haxe/RailsViewComponent.hx
rails_view_component-0.0.2 lib/rails_view_component/haxe/RailsViewComponent.hx
rails_view_component-0.0.1 lib/rails_view_component/haxe/RailsViewComponent.hx