B4J Question ABMaterial - ABMImageSlider does not work together with ABMCalendar

Javier Lovay

Member
Licensed User
Longtime User
I have a problem when inserting an ABMImageSlider component together with ABMCalendar, if they are together, ABMImageSlider does not show any image and appears in a gray rectangle. On the contrary, without ABMCalendar, ABMImageSlider works perfectly. How can I solve that? I need them to be working together. Greetings and thanks.


B4X:
 ' Crear control deslizante
Control deslizante de atenuación como ABMImageSlider
slider. Inicializar(página, "slider", "slider300")
 
' agregar imágenes
slider. AddSlideImage(".. /images/slider1.jpg","This is our big Title!", "Here's a small slogan.", ABM. IMAGESLIDER_LEFT)
slider. AddSlideImage(".. /images/slider2.jpg","This is our big Title!", "Here's a small slogan.", ABM. IMAGESLIDER_CENTER)
slider. AddSlideImage(".. /images/slider3.jpg","This Is our big Title!", "Here's a small slogan.", ABM. IMAGESLIDER_RIGHT)
slider. AddSlideImage(".. /images/slider4.jpg","This is our big Title!", "Here's a small slogan.", ABM. IMAGESLIDER_CENTER)
 
página. Celda(2,1). AddComponent(control deslizante)

'    Dim calendario As ABMCalendar
' DateTime.DateFormat = "aaaa-MM-dd"
' calendario. Initialize(page, "calendario", DateTime.Date(DateTime.Now), 0, "es", ABM. CALENDAR_DEFAULTVIEW_WEEK, "calendario")
' DateTime.DateFormat = "dd/MM/aaaa"
' calendario. Editable = Verdadero
' calendario. IsPrintable = Verdadero
' calendario. ChangeEventsEditable(True)
' página. Celda(2,1). AddComponent(calendario)
[/CÓDIGO] [/CÓDIGO] [/CÓDIGO]
 
Last edited:

alwaysbusy

Expert
Licensed User
Longtime User
I've identified the problem. It looks like the calendar overwrites the slider method attached to the jQuery element. Unfortunately I can not release a new version of ABM at this time as it has already been converted for Jetty 4.00, which an official final version has not been released yet.

A temporary workaround could be this:

Open the file 'core.4.96.min.js' in the www/js/ folder. Do a find for (only one occurence):

B4X:
f.fn.slider

And replace it by:

B4X:
f.fn.abmslider

Save the file.

In your code AFTER you've added both components AND did the page.refresh, add this snippet:

B4X:
' adding your 2 components
...
' refresh the page
page.Refresh    
' Tell the browser we finished loading
page.FinishedLoading
' restoring the navigation bar position
page.RestoreNavigationBarPosition
...
' --------------- add this -------------------------
Dim Script As String = $"$('#slider').find('li').removeClass('active');
$('#slider').find('.indicator-item').removeClass('active');
$('#slider').find('.indicators').remove();
$('#slider').abmslider({full_width: true ,indicators: true ,height: 400 ,transition: 500 ,interval: 6000});"$

page.ws.Eval(Script, Null)
page.ws.Flush
' ----------------------------------------

Alwaysbusy
 
Upvote 0

Javier Lovay

Member
Licensed User
Longtime User
Alain, cuando los componentes están dentro de un ABMContainer la solución propuesta no funciona. Seguro que encuentras algún consejo para darme. Muchas gracias.
 
Upvote 0

Javier Lovay

Member
Licensed User
Longtime User
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Can we continue in English as I don't speak Spanish. Also there is something wrong with the code you post as it seems to be translated to Spanish too which makes it pretty unusable for me to test.

If something is in a container, you do indeed have to change the ID in the snippet. This is because ABM makes sure an ID in html is unique (it has to be) and with nested tags (like a label in a container) it does it by concatenating the parent IDs + (optional) Array + label ID.

Here is a helper method that uses one of my Debug methods that can be helpful to find the real ID of a component in the browser by code:

B4X:
public Sub GetRealID(ID As String) As String
    Dim spl() As String = Regex.Split(",", ID)
    Return spl(0).SubString2(8,spl(0).Length-1) & spl(1).SubString2(11,spl(1).Length-1) & spl(2).SubString2(4,spl(2).Length-1)
End Sub

Usage:
B4X:
Log(GetRealID(btn2.GetDebugID)) ' <--- converts the debug ID to the real ID

It is something you normally don't have to worry about, as ABM will take care of it. But in case you manipulate the html outside of ABM (e.g. with a javascript), you have to do this yourself.

Alwaysbusy
 
Upvote 0

Javier Lovay

Member
Licensed User
Longtime User
Sorry, I translated the text to English, but I have Chrome's automatic translation activated and it returned it to Spanish. Your solution works perfect. Thank you very much for your help.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…