Forum Discussion
JohnBarulich1
7 years agoQrew Cadet
Thanks Dan,
In your code snippet previously stated, it doesn't look like we are specifying any context for the selection. How would we specify context for this selection? How would this statement, which specifies position, be executed within the script if it will not fire until the button is pushed?
I can't seem to get a simple button onto the top with
$("table[qbdbid=" + dbidTable + "] tr:first").before("<tr><td><a href=# id=QBU_Button class='Vibrant Success'>Process Selected Records</a></td></tr>");
In your code snippet previously stated, it doesn't look like we are specifying any context for the selection. How would we specify context for this selection? How would this statement, which specifies position, be executed within the script if it will not fire until the button is pushed?
I can't seem to get a simple button onto the top with
[iol] & "myScript.js" & [/iol]
&
"<a class='QBU_Button Vibrant Success'>Button</a>"
_anomDiebolt_
7 years agoQrew Elite
Display a table report and paste this code into the console:
To implement this you could set up the IOL technique and include the IOL field [-] in the report - typically as the last column of the report to not call attention to itself (it will be a skinny column). The formula for [-] will be just this:
BTW, I think it is best to always name your code page with the prefix "module" followed by the name of the table and perhaps the function of the script. Examples:
var dbidTable = "your table dbid";It will splice a button atop the report and establish a listener for clicks on that button. When you click the button the callback will execute in this case alerting a message.
$("table[qbdbid=" + dbidTable + "] tr:first").before("<tr><td><a href=# id=QBU_Button class='Vibrant Success'>Pinch Me</a></td></tr>");
$("#QBU_Button").on("click", function(event) {
alert("Ouch!");
});
To implement this you could set up the IOL technique and include the IOL field [-] in the report - typically as the last column of the report to not call attention to itself (it will be a skinny column). The formula for [-] will be just this:
[iol] & "myScript.js" & [/iol]The code snippet you pasted is for setting up a button on each row of a report:
[iol] & "myScript.js" & [/iol]Although it would normally pass the [Record ID#] through a data attribute:
&
"<a class='QBU_Button Vibrant Success'>Button</a>"
[iol] & "myScript.js" & [/iol]And obtain the record id in the script as follows:
&
"<a class='QBU_Button Vibrant Success' " &
" data-rid='" & [Record ID#] & "'" &
">Button</a>"
$("a.QBU_Button").on("click", function(event) {});
var rid = this.dataset.rid;
var message = 'You clicked on record with rid=${rid}';
alert(message);
BTW, I think it is best to always name your code page with the prefix "module" followed by the name of the table and perhaps the function of the script. Examples:
moduleTable1.js
moduleTable1Form1.js
moduleTable1UpdateSomething.js