Announcement

Collapse
No announcement yet.

jqButton with AddScript()

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Guahtdim
    replied
    I made my own solution

    https://forums.homeseer.com/forum/de...77#post1354977

    Leave a comment:


  • Guahtdim
    replied
    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:


  • dcorsus
    replied
    Did you guys finally got this confirmation box/function to work?
    Thanks for sharing
    Dirk

    Leave a comment:


  • rmasonjr
    replied
    Excellent - thanks Wade!

    Leave a comment:


  • Sgt. Shultz
    replied
    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:


  • rmasonjr
    replied
    Originally posted by wetlip View Post
    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
    Yes, that adds the script code, but it never gets called. I think if it somehow does get called, the post/postback will still occur regardless if you press ok or cancel.

    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:


  • wetlip
    replied
    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:


  • rmasonjr
    replied
    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_NAMEFalse)
            
    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
    It looks to be the same as before - no effect on includeClickFunction=True

    Am I right in thinking that this is how AddScript works with the jqButton?

    Leave a comment:


  • Sgt. Shultz
    replied
    It looks like you need to set the includeClickFunction to true as well.

    Leave a comment:


  • rmasonjr
    started a topic jqButton with AddScript()

    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_NAMEFalse)
            
    b.AddScript("function userConfirm() {  confirm(""hey - are you sure??"");  }")
            
    b.functionToCallOnClick "userConfirm()"
            
    sbtb.Append(b.Build
    When it builds the page, I see in the source view that the function is built, but the button does not have an onClick property and the script never gets called. For that matter, I do not see the confirm("hey are you sure??") in there either...
    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
    So, how should we use AddScript to have a jqButton call a script?
Working...
X