dar2o3 Active Member Licensed User Longtime User Mar 9, 2016 #1 Hi to all. I have this B4X: <ul id="dropdown1" class="dropdown-content"> <li id='1'><a href="#!">one</a></li> <li id='2'><a href="#!">two</a></li> <li class="divider"></li> <li id='3'><a href="#!">three</a></li> </ul> in my code this B4X: Sub dropdown1_Click (Params As Map) End Sub as I get the value of the label <a> <li> selected? Get the id of the <li> selected is sufficient. Last edited: Mar 9, 2016
Hi to all. I have this B4X: <ul id="dropdown1" class="dropdown-content"> <li id='1'><a href="#!">one</a></li> <li id='2'><a href="#!">two</a></li> <li class="divider"></li> <li id='3'><a href="#!">three</a></li> </ul> in my code this B4X: Sub dropdown1_Click (Params As Map) End Sub as I get the value of the label <a> <li> selected? Get the id of the <li> selected is sufficient.
dar2o3 Active Member Licensed User Longtime User Mar 9, 2016 #2 There are actually several <ul> <li> nested B4X: <ul class="right hide-on-med-and-down" id="menuxa"> <ul id=Empresa class=dropdown-content> <li> <a href=../asegurado/empresas.html>Datos empresa</a> </li> </ul> <ul id=Viajes class=dropdown-content> <li><a href=../asegurado/viajes.html>Nuevo viaje</a> </li> </ul> <li> <a class=dropdown-button href=#! data-activates=Empresa> Empresa <i class=right><i class=material-icons> arrow_drop_down</i></i></a> </li> <li> <a class=dropdown-button href=#! data-activates=Viajes> Viajes<i class=right> <i class=material-icons> arrow_drop_down</i></i></a> </li> <li id=cierre name=cierre> <a href=#>Cerrar sesión</a> </li> </ul> And B4X: Sub menuxa_Click (Params As Map) Dim target As String = Params.Get("target") Log(target) End Sub target is empty. I am interested recover when the id = "cierre" is pressed html text not has quotes because I copied the log, but it is correct, there is not the problem Last edited: Mar 9, 2016 Upvote 0
There are actually several <ul> <li> nested B4X: <ul class="right hide-on-med-and-down" id="menuxa"> <ul id=Empresa class=dropdown-content> <li> <a href=../asegurado/empresas.html>Datos empresa</a> </li> </ul> <ul id=Viajes class=dropdown-content> <li><a href=../asegurado/viajes.html>Nuevo viaje</a> </li> </ul> <li> <a class=dropdown-button href=#! data-activates=Empresa> Empresa <i class=right><i class=material-icons> arrow_drop_down</i></i></a> </li> <li> <a class=dropdown-button href=#! data-activates=Viajes> Viajes<i class=right> <i class=material-icons> arrow_drop_down</i></i></a> </li> <li id=cierre name=cierre> <a href=#>Cerrar sesión</a> </li> </ul> And B4X: Sub menuxa_Click (Params As Map) Dim target As String = Params.Get("target") Log(target) End Sub target is empty. I am interested recover when the id = "cierre" is pressed html text not has quotes because I copied the log, but it is correct, there is not the problem
DonManfred Expert Licensed User Longtime User Mar 10, 2016 #3 What does B4X: log(Params) print to the log? Upvote 0
dar2o3 Active Member Licensed User Longtime User Mar 10, 2016 #4 Thanks for answering. The result of the print the log is this. B4X: (MyMap) {which=1, metaKey=false, pageY=30, pageX=994, target=} I am using the framework materializecss, not if the problem may come from the framework or am I doing something wrong. Upvote 0
Thanks for answering. The result of the print the log is this. B4X: (MyMap) {which=1, metaKey=false, pageY=30, pageX=994, target=} I am using the framework materializecss, not if the problem may come from the framework or am I doing something wrong.
Erel B4X founder Staff member Licensed User Longtime User Mar 10, 2016 #5 Add this code to the Connected event (it adds a click event to the list items): B4X: ws.Eval($" $('#dropdown1 li').on('click', function () { b4j_raiseEvent("item_click", {index: $(this).index()}); });"$, Null) Handle the event with: B4X: Sub Item_Click (Params As Map) Log($"Clicked on item ${Params.Get("index")}"$) End Sub Upvote 0
Add this code to the Connected event (it adds a click event to the list items): B4X: ws.Eval($" $('#dropdown1 li').on('click', function () { b4j_raiseEvent("item_click", {index: $(this).index()}); });"$, Null) Handle the event with: B4X: Sub Item_Click (Params As Map) Log($"Clicked on item ${Params.Get("index")}"$) End Sub
dar2o3 Active Member Licensed User Longtime User Mar 10, 2016 #6 just perfect, now I can use this to get the text, interests me more than the index. B4X: ws.Eval($" $('#menuxa').on('click','li', function (){b4j_raiseEvent("item_click",{texto: $(this).text()});});"$, Null) and B4X: Sub Item_Click (Params As Map) Log($"Clicked on item ${Params.Get("texto")}"$) End Sub Thank you very much for to answer my question. Last edited: Mar 10, 2016 Upvote 0
just perfect, now I can use this to get the text, interests me more than the index. B4X: ws.Eval($" $('#menuxa').on('click','li', function (){b4j_raiseEvent("item_click",{texto: $(this).text()});});"$, Null) and B4X: Sub Item_Click (Params As Map) Log($"Clicked on item ${Params.Get("texto")}"$) End Sub Thank you very much for to answer my question.