Jump to content

Recommended Posts

Posted

Hi,

 

One of the possible solutions at the moment I think:

procedure TMainForm.UniFormReady(Sender: TObject);
begin
  UniSession.AddJS(Self.Name+'.'+Item11.Name+'.setIconCls("test");');
end;

Best regards,

  • 5 weeks later...
Posted

New question :

i'm using your code like this :

procedure SetMenuItemImg(aForm : TUniForm;aMenuItem : TUniMenuItem; aSvg : string);
begin
  UniSession.AddJS(aForm.Name+'.'+aMenuItem.Name+'.setIconCls("'+UniMainModule.MainColorClass+' fs16 '+aSvg+'");');
end; 

Now my menu is on a TuniFrame. if i change uniform by uniframe it is not working.

 

How can i do it or how can i access to JSName or JsId property for my frame ?

Posted

i call in the on framecreate.

I try this 

procedure SetMenuItemImg(aFrame : TUniframe;aMenuItem : TUniMenuItem; aSvg : string);
begin
  UniSession.AddJS(aFrame.Name+'.'+aMenuItem.Name+'.setIconCls("'+UniMainModule.MainColorClass+' fs16 '+aSvg+'");');
end; 

but it is not working.

in console :  MyFrameName is undefined. so it is the reason that i try to access to jsname or jsid because they would be unique.

Posted

Hi,

 

Can you try this ?!:

procedure TUniMenuFrame.UniFrameCreate(Sender: TObject);
begin
  Self.OwnerWebForm.JSInterface.JSAddListener('boxready', 'function(me){me.owner.'+ Item11.Name +'.setIconCls("testIcon")}');
end;

Best regards,

Posted

You probably can't do it OnCreate as the frame might not be defined yet as it it is still in the constructor, probably needs to move the responsibility to the owner form where you know the frame has been created. (hence after create)

Posted

Try this:

procedure TUniMenuFrame.UniFrameAjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName='_ready' then
  begin
    UniSession.AddJS(Params.Values['_nm'] + '.owner.' + Item11.Name + '.setIconCls("testIcon")');
  end;
end;

procedure TUniMenuFrame.UniFrameCreate(Sender: TObject);
begin
  ClientEvents.ExtEvents.Add('boxready=function boxready(sender, width, height, eOpts){ajaxRequest(sender, "_ready", ["_nm="+sender.nm])}');
end;
  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...