PDA

View Full Version : [CLOSED] Button Icon



bbros
Sep 20, 2021, 3:06 PM
Hello!
I need to draw a flag icon in a button in order to show the selected language.
The button is in _Header.cshtml, so I don't have codebehind.
I would like to set it via javascript.

The following code works fine:


<ext-button id="LanguageButton"
variant="Light"
scale="Medium"
text=""
hidden="false"
icon="/images/flag_italy.png"
margin="5"
onClientClick="">
<menu>
<ext-menu plain="true">
<items>
<ext-menuItem id="LangItMenuItem" text="Italiano" icon="/images/flag_italy.png">
<listeners>
<click handler="alert('Italiano!');" />
</listeners>
</ext-menuItem>
<ext-menuItem id="LangEnMenuItem" text="English" icon="/images/flag_usa.png">
<listeners>
<click handler="alert('English!');" />
</listeners>
</ext-menuItem>
</items>
</ext-menu>
</menu>
</ext-button>

I would like to create a js which reads inside a cookie the preferred language and sets the correct icon to the LanguageButton.

App.LanguageButton.setIcon('...') or App.LanguageButton.icon = '...' do not work;
I tried to use the iconCls but it becomes white (maybe because of a wrong implementation).



.bbros-flag-it {
background:url(/images/flag_italy.png);
}


Could you please help me?
Thank you much!

bbros
Sep 21, 2021, 8:54 AM
I'm sorry for asking you, I don't know what was wrong yesterday but

App.LanguageButton.setIcon('/images/flag_usa.png')

do work as expected.

fabricio.murta
Sep 22, 2021, 7:49 PM
Hello @bbros!

Sorry for the delay getting back to you.

I'm not sure why you are randomly getting it. There could have been a typo, maybe? I have tested a sample using your code block and it referenced the image URL the way we would expect. Of course, in my case it was blank simply because I didn't have any file in the specified path. Once the file was fixed, it was displayed.

Anyway, let us know if this issue hits you again!

bbros
Sep 24, 2021, 9:57 AM
Thank you, it is still working... I really don't know what happened.
you can consider this thread as closed.

fabricio.murta
Sep 25, 2021, 4:00 PM
Alright, thanks for the feedback, and glad it didn't happen again, hopefully never will! :)

Marking as closed.