I made my own solution
https://forums.homeseer.com/forum/de...77#post1354977
Announcement
Collapse
No announcement yet.
jqButton with AddScript()
Collapse
X
-
Almost 7 years after and I have the same problem. How to implement a "Are you sure dialog". Does anyone have a some code to show me?
Leave a comment:
-
Did you guys finally got this confirmation box/function to work?
Thanks for sharing
Dirk
Leave a comment:
-
The problem is the script variable is being cleaned just prior to building the object.
Adding your script to the top of your page should fix this.
Leave a comment:
-
Originally posted by wetlip View Postyou could add this as a string after adding button build.
addscript isnt documented, is it like you see it or is it a reference to a script file.
PHP Code:<script type='text/javascript'> userConfirm() { confirm(""hey - are you sure??""); }</script>
I dont believe AddScript references a file - my assumption is that it allows you to do some inline js for jquery. Since it's not documented, that is a big assumption
HST - we really would like some way to prompt the user with "Are you sure?" for jqButton.
Leave a comment:
-
you could add this as a string after adding button build.
addscript isnt documented, is it like you see it or is it a reference to a script file.
PHP Code:<script type='text/javascript'> userConfirm() { confirm(""hey - are you sure??""); }</script>
Leave a comment:
-
I added that property and the generated code still is not bringing over my function from the AddScript:PHP Code:Dim b As New clsJQuery.jqButton("btnTestConnection", "Test Connection", IFACE_NAME, False)
b.AddScript("function userConfirm() { confirm(""hey - are you sure??""); }")
b.functionToCallOnClick = "userConfirm()"
b.includeClickFunction = True
sbtb.Append(b.Build)
When I do a view/source, this is the script area for the button:PHP Code:<script>
$(function() {
$('#btnTestConnection_ID598385').button({icons: {primary:'',secondary:''} });
$('#btnTestConnection_ID598385').click(function() {
userConfirm()
var theData='';
returnTrue = false
theData = theData+'&id='+this.id+'&btnTestConnection=Submit';
commonAjaxPost(theData,'MyPlugin');
if(returnTrue) {
location.reload();
return false;
}
else {
return false;
}
});
});
</script>
<button type='submit' id='btnTestConnection_ID598385' name='btnTestConnection' >Test Connection</button>
Am I right in thinking that this is how AddScript works with the jqButton?
Leave a comment:
-
It looks like you need to set the includeClickFunction to true as well.
Leave a comment:
-
jqButton with AddScript()
Since we still cant search this forum, I'll post the question here - not sure if it has been covered...
I have a jqButton defined and am trying to call a script for the onClick:
PHP Code:Dim b As New clsJQuery.jqButton("btnTestConnection", "Test Connection", IFACE_NAME, False)
b.AddScript("function userConfirm() { confirm(""hey - are you sure??""); }")
b.functionToCallOnClick = "userConfirm()"
sbtb.Append(b.Build)
PHP Code:<script>
$(function() {
$('#btnTestConnection_ID598385').button({icons: {primary:'',secondary:''} });
$('#btnTestConnection_ID598385').click(function() {
userConfirm()
var theData='';
returnTrue = false
theData = theData+'&id='+this.id+'&btnTestConnection=Submit';
commonAjaxPost(theData,'My Plugin');
if(returnTrue) {
location.reload();
return false;
}
else {
return false;
}
});
});
</script>
<button type='submit' id='btnTestConnection_ID598385' name='btnTestConnection' >Test Connection</button>
Tags: None
Leave a comment: