Hello, i am trying out AppBuilder, and trying to use a button to incrementally show images. That works fine, but when it reaches the last image available, I want it to go to the first image; the number of images will vary as I add more.
I tried using javascript in the button code to check if image exists, but it seems to ignore the script. I have the following:
(images are named 1a.jpg, 1b.jpg, then 2a.jpg, 2b.jpg, etc. (when I click on the image 1a.jpg, it loads 1b.jpg, etc.))
The javascript works outside of appbuilder, in a simple web page, but not in the button code area. Can you advise any simple way to verify if an image exists in folder so I can redirect to first image when image called doesn't exist?
Appreciate your help.
Roger
Hello,
Maybe you can prepare the Javascript function as an app's function in order to be called from the button's event. The code that you shown may can work, but, the Javascript code must be placed between the actions StartJS and EndJS actions in this way:
The External Javascript help topic can be also of your interest, for example, to access AB stuff (variables, etc.) from Javascript code.
Hope this can help you in some way.
Thanks for the quick reply; ok, I added the Start/End js; Below is my rough code. It runs through and checks if each image exists, then shows it in AB. When it gets to an image that doesn't exist (ie there is no 8a.jpg), I try to use javascript to re-value window.App.RootScope.picnumber3="1a.jpg" (back to first image). But when I run this, the log shows:
And AB still sees the [picnumber3] is not changed back to the 1a.jpg (first image). Am I setting value of the window.App.RootScope.picnumber3 variable correctly? Failing that, is there a way in AB to capture the "Unresolved" error to flag when to change the value in AB itself?
Let me know if this is not clear. I am enjoying learning from your program!
Thanks
Roger
Hello,
Without doubt the "Unresolved" error means the image's URL doesn't exists. The variable's assignment appear good to me. I am not sure if this can help you in this specific case, but I update App Builder and now the Image control has an Error event ready to be used, so please update your AB trial now.
If you have a further question, please, maybe you can prepare a little sample application in which I can take a look at what you expected and what you get. Feel free to use the Forum's upload section or send me an email to: info AT davidesperalta DOT com.
yesterday I was the same situation.I fix it by add image to project files and use path "app/images/h01.png".then use some javascript to control it.(I made cardview by using swiper as manual for user.)
Hello to all,
yesterday I was the same situation.I fix it by add image to project files and use path "app/images/h01.png".then use some javascript to control it.(I made cardview by using swiper as manual for user.)
The recently added Image's control's Error event may can help you too Tin! Take a look!
Okay thanks for the update, installed it ok. Now, hopefully last question before I can get this together. You mentioned: the Image control has an Error event ready to be used. If I give you some pseudo-code can you show me how to address/trap the error event?
Can you give me a code example how to access and use the image error event? I think once I grasp that I can put this together.
BTW- I notice where you live on your tag; I lived in Aravaca for 5 years (back in the 70's - a lot has changed!). Anyway, nice to meet someone from the old neighborhood, and hello from Oregon.
Thanks
Roger
Hello Roger,
The Image's Error event is available in the Events tabs of the control: just double click the Image control that you wanted, and then, you enter into the Events tabs. Just look to the "Error" one and place the code that you wanted in that place. I prepare an small application sample for you:
ImageErrorEvent.ab (Right click and choose "Save link as...")
Please, let me know if you have any further question sir.
Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.