Issue with triggering jquery using HTMLsnippet

0
Hi all, I am trying to implement a function to a) first add an item to a listView and b) scroll the listView to the bottom. a) Adding the item to the list view is done via microflow triggered from a button (name = sendBtn) b Scrolling to a botton of the list view shall be done with jquery snippet, that is triggered by the button. Here is the current state of the implementation: I use the HMTLsnippet (enable JavaScript with jquery). I have double checked in the jquery docu: how to bind a function to a button using jquery (https://api.jquery.com/click/). how to scroll to the end of a container using jquery (https://api.jquery.com/scrollTop/#scrollTop)   Then I have extracted the CSS class for the button and the list view from the DOM: Button: btn mx-button mx-name-btn1 btn-default ListView: mx-listview mx-listview-selectable mx-name-listView1 listview-stylingless   $(".mx-name-sendBtn").click(function(){ $(".mx-name-listView1").scrollTop(700) }); However, triggering the sendBtn does not lead to a scrolled down listView. Any suggestions would be great!
asked
1 answers
0

Hi Tym,

Have you seen the javascript button? From the documentation “A Mendix button widget that can run custom JavaScript. You can even run a microflow before or after the JavaScript.” There is a setting to enable jquery, you could try using this instead of the html snippet to bind the script to your button.

https://appstore.home.mendix.com/link/app/27064/Mendix/JavaScript-Button

 

Edit: You can try this for your hello world 

https://www.w3schools.com/js/js_popup.asp

 

To query an element I usually use classes since the IDs are dynamic. You can try hasClass

https://api.jquery.com/hasclass/

 

answered