#1 2016-11-18 06:58:04

starin
Banned
Registered: 2016-11-09
Posts: 12

How to Set an various Image's Popover Text in runtime

hi every one,

there is many image controls in my view1 and their name is : Image1  Image2 , .....
and want to set their PopoverText , so i create a function with it's own arguments [ID] , [N] and call it , but this not work.

SetVar "Image[ID].PopoverText" "[N]" "String"

Thanks

Last edited by starin (2016-11-18 07:14:44)

Offline

#2 2016-11-18 09:11:08

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: How to Set an various Image's Popover Text in runtime

Hello starin,

I am very sorry, but the App Builder's script doesn't support nested variables. As a possible workaround, are you trying to use Javascript directly in this case? Take a look at the External Javascript tutorial for more information.

Offline

#3 2016-11-18 09:52:19

starin
Banned
Registered: 2016-11-09
Posts: 12

Re: How to Set an various Image's Popover Text in runtime

Thanks david,
yes i know about java script sample , but  the problem is i don't know how to set a special image control popovertext.

this code work fine :

StartJS
  window.App.View1.Scope.Image1.PopoverText = [N] ;
EndJS

i know this code is false but i want to do something like this (there is many pictures so i need to set they by ID):

StartJS
  window.App.View1.Scope.Image[ID].PopoverText = [N] ;
EndJS

Last edited by starin (2016-11-18 09:55:25)

Offline

#4 2016-11-18 11:01:34

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: How to Set an various Image's Popover Text in runtime

Hello starin,

Looking at the code I think the scope is not the correct: must be something like "window.App.RootScope.Image". On the other hand, we can't mix AB variables with JS variables in the same JS code. However, I think we meet another problem starin, because follow my previous notes you can thinking on write something like this:

window.App.RootScope.Image[window.App.RootScope.N].PopoverText = window.App.RootScope.N;

But the above code can't work as expected, because "Image" is not an Array of objects, so we can't use any kind of "index" property here. Then in order to achieve what you wanted, I think we must iterate over all the images, and then assign their appropiate "uib-popover" attribute. This can be does by a code like the below one:

StartJS

  var
    popoverImgs = document.getElementsByClassName('popoverImg');

  for (var I = 0; I < popoverImgs.length; I++) {
    popoverImgs[I].setAttribute('uib-popover', 'My popover ' + I);
  }

EndJS

However, that code doesn't work as expected... Certainly the appropiate "uib-popover" is set (we can see it in the Firefox Inspector, for example) but the popover doesn't works as expected. I am try by upgrading the UI Bootstrap library behind the popovers but without success.

I will investigate a little more about this because I am not sure about what can happend here. Maybe I can open an issue into the UI Boostrap project page in order to get some possible help. I am sorry starin but right now you must look for some possible alternative or approach. I will inform here on any news.

Offline

#5 2016-11-18 11:23:55

starin
Banned
Registered: 2016-11-09
Posts: 12

Re: How to Set an various Image's Popover Text in runtime

Thanks david smile

Last edited by starin (2016-11-18 11:24:18)

Offline

#6 2016-11-18 11:25:23

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: How to Set an various Image's Popover Text in runtime

Hello starin,

No problem. Just now I am working to upgrade the UI Bootstrap library to the latest version (lot of internal changes must be made) in order to assert we are using it. Then I will to do some other tests in order to achieve what you wanted. I will inform here on any news.

Offline

#7 2016-11-18 12:34:58

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,657
Website

Re: How to Set an various Image's Popover Text in runtime

Hello starin,

First of all update your AB copy starin (please consider to buy a license if App Builder is useful for you) because I upgrade the UI Bootstrap library that, between other things, enhance the tooltips and popovers with new possible position and event values.

On the other hand, after a hard research I finally remember that certainly "Image" is not Array, but "RootScope" it is. Then the below code works as expected and may you can adapt to your requeriments. Of course post here if you have any further question.

StartJS

  for (var I = 1; I <= 4; I++) {
    window.App.RootScope["Image" + I].PopoverText = 'My new Popover ' + I;
  }

EndJS

* The above code changes the "PopoverText" variable of the (suposed) "Image1", "Image2", "Image3" and "Image4" controls.

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.