Jump to content

Ajax Error with getEl method using AddJS


cristianotestai
 Share

Recommended Posts

Hi Farshad,

 

Use the event below to place an image in UniEdit and works ok!

 OnAfterrender function (sender)
 {
  sender.getEl().setStyle('background-image', "url ([url="http://localhost:8077/ext-3.4.0/resources/images/search.gif"]http://localhost:807...ages/search.gif[/url])");
 }

 

What I am not able to do is use the Event "OnEnter" of "UniEdit" to add in runtime the UniSession.AddJS command under certain condition.

 

I'm trying:

 

procedure TfmContato.edFiltroNomeEnter(Sender: TObject);
begin
 if (edFiltroNome.Text = 'buscar') and (edFiltroNome.Font.Color = $00B5B5B5) then
 begin
  UniSession.AddJS('fmHome.edFiltroNome.getEl().setStyle(' + QuotedStr('background-image') +
	', "url([url="http://localhost:8077/ext-3.4.0/resources/images/search.gif"]http://localhost:807...ages/search.gif[/url])");');
 end;
end;

 

And AjaxError occurs: Can not call method 'getEl' of undefined. I do not understand why that the method is not defined, if it is used in OnAfterrrender,

where the object "edFiltroNome" is the same object.

 

How to do the same as the event OnAfterrender at runtime using the UniSession.AddJS and also, how to eliminate the code in the event OnExit later?

 

Attached the error image.

 

Thanks.

Link to comment
Share on other sites

Where is "fmHome" was defined?

 

IMO, it's safer when we reference to component's name property instead of a constant one.

 

Hi,

 

fmHome is my MainModule name. I'm using the constant because it is the name of MainModule, to which the principle in this project will always be 'fmHome'.

 

Regards.

Link to comment
Share on other sites

  • Administrators

Hi Farshad,

 

Use the event below to place an image in UniEdit and works ok!

 OnAfterrender function (sender)
 {
  sender.getEl().setStyle('background-image', "url ([url="http://localhost:8077/ext-3.4.0/resources/images/search.gif"]http://localhost:807...ages/search.gif[/url])");
 }

 

 

Please send a test case.

Link to comment
Share on other sites

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.

 Share

×
×
  • Create New...