farshadmohajeri / extpascal

Automatically exported from code.google.com/p/extpascal
49 stars 28 forks source link

TExtObject.Ajax(string) does not add the Obj parameter #63

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
This Ajax overload:

function TExtObject.Ajax(MethodName : string; Params : array of const; IsEvent 
: boolean = false) : TExtFunction;

does not add the Obj parameter to the generated JS code, unless IsEvent is True.

It is useful, at times, to call this method on an instance with a computed 
(i.e. not fixed) method name, so I propose that the Obj param is always added:

function TExtObject.Ajax(MethodName : string; Params : array of const; IsEvent 
: boolean = false) : TExtFunction;
var
  lParams : string;
begin
  InJSFunction := false;
  Result  := TExtFunction(Self);
  lParams := IfThen(JSName = '', '', 'Obj=' + JSName);
  if IsEvent then begin
    lParams := lParams + '&IsEvent=1&Evt=' + MethodName;
    MethodName := 'HandleEvent';
  end;
  AjaxCode(MethodName, lParams, Params);
end;

Note: this version also fixes a glitch in which an extra & (resulting in an 
empty param) was being put in the generated code.

Original issue reported on code.google.com by nando.dessena on 11 Aug 2011 at 4:33