Examples
A sample Bubble app containing Toolbox examples:
-
App preview of test version, with debug mode
Filtering a Bubble list in javascript
-
A repeating group showing a list of books
-
Workflow with Run javascript
-
Run javascript parameter sends the book list to javascript (I could have used a Search instead of the RG)
-
Script to run, filters out any Alex titles, sends the list to Javascript to Bubble
var mylen = properties.paramlist1.length(); var mylist = properties.paramlist1.get(0,mylen); // filter out books with title that starts with Alex var myfiltered = mylist.filter(b=>!b.get('title_text').startsWith("Alex")); bubble_fn_books( myfiltered );
-
Javascript to Bubble returns the filtered list to Bubble
-
Another repeating group shows the filtered list
This example is in the demo app Editor
Sort and modify API result list in javascript
Similar to the previous example, but this time using data sourced from an API call.
Also demonstrates altering an item!
var mylen = properties.paramlist1.length();
var mylist = properties.paramlist1.get(0,mylen);
// show internal name for fields
console.log(mylist[0].listProperties());
// sort descending
mylist.sort((a, b) => b.get('_api_c2_userId') - a.get('_api_c2_userId'));
// alter second item in sorted list
mylist[1] = {
"_api_c2_userId": 999,
"_api_c2_id": 888,
"_api_c2_title": "Bet ya didnt expect this post",
"_api_c2_body": "Running like rubber chicken"
};
bubble_fn_sorted(mylist)
This example is in the demo app Editor
Using Expression to generate a list of dates
d = new Date().getTime();
ds = [];
for(i=0; i<10; i++) ds.push(new Date(d+(i*86400000)));
ds;