Page 1 of 1

Async rendering a JQMRegion

PostPosted: 05 Mar 2014 10:12
by Davide
Hello,

I would like to show a runtime created list of JQMLabel in a JQMRegion by clicikng a JQMButton.
Following is the code I'm testing (derived form the same I'm using in a IWCGJQuery application):
Code: Select all
         if (CGIsCallBackProcessing) then
            CGCallBackDisableAjaxResponse;

         for I := 0 to MyStringList.Count -1 do begin
            MyItem := TMyObject(MyStringList.Objects[I]);
            LblD := TIWCGJQMLabel.Create(Self);
            LblD.Parent := MyRegion;
            LblD.TabOrder := i;
            LblD.Text := MyItem.Text;
            LblD.Visible := true;
         end;

         if (WebApplication.CallBackProcessing) then
            CGCallBackEnableAjaxResponse;
         RenderRegionAsync(MyRegion);


The code is executed but the JQMLabel list is not shown.
Is it possible ?
What's wrong with what I am doing ?

Thank you,
Davide

Re: Async rendering a JQMRegion

PostPosted: 05 Mar 2014 13:37
by Jorge Sousa
Hi

You cannot do this:

if (WebApplication.CallBackProcessing) then
CGCallBackEnableAjaxResponse;

after you call

if (CGIsCallBackProcessing) then
CGCallBackDisableAjaxResponse;

WebApplication.CallBackProcessing returns false

so you must use, instead, the method as it is in the demos:

var
IsAsync: Boolean;
begin
IsAsync:= WebApplication.CallBackProcessing;
if IsAsync then
CGCallBackDisableAjaxResponse;
try
{....}
finally
if IsAsync then
CGCallBackEnableAjaxResponse;
end;
RenderRegionAsync(MyRegion);
end;

Re: Async rendering a JQMRegion

PostPosted: 05 Mar 2014 15:08
by Davide
Hello,

I can't find the IWCGJQMobile demo from where you extract the code reported in your post...
What project is it ?

I tryied to implement your solution but the region isn't updated and it doesn't show the runtime created label.
The code execute without any error but without any results.

Following what I coded:
Code: Select all
            IsAsync := WebApplication.CallBackProcessing;
            if (IsAsync) then
               CGCallBackDisableAjaxResponse;

            try
            for I := 0 to MyLabelsList.Count -1 do begin
                  LblD := TIWCGJQMLabel.Create(Self);
                  LblD.Parent := MyRegion;
                  LblD.TabOrder := I;
                  LblD.Text := MyLabelsList[i];
               end;
            finally
               if IsAsync then
                  CGCallBackEnableAjaxResponse;
            end;
            RenderRegionAsync(MyRegion);
         end;


Do you have any suggestions to achieve the results I need ?

Thank you,
Davide

Re: Async rendering a JQMRegion

PostPosted: 05 Mar 2014 15:15
by Jorge Sousa
The RenderAsync examples are in jQueryDemo and jQueryDemo_V2

You also forgot to set the Name

LblD := TIWCGJQMLabel.Create(Self);
LblD.Name:= 'SomeLabelName';