facebook

Replace the "Run JavaScript" code of a button

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #344290 Reply

    Bestmoose
    Participant

    How can I access and change the code, that a button will perform if the ‘On Click’ action is set to “Run JavaScript”?
    Let’s say button “push1” is set to Run JavaScript with the code “countToThree();” and I want to change this while the App is running to “countToFour();”

    Is there something similar to the property <button.value> respectively <button.childNodes[0].nodeValue> (for the label text of a button) that can change its ‘On click’ action code?
    If not, I’ll have to find a work-around, but it would be nice to do it this way.

    For my purpose it would already be enough to get the Id of a button that fires a function within JavaScript, that way I could referrence my actions depending on the button-Id and use the same ‘On Click’ JavaScript in all my buttons.

    I know… I am getting annoying :-O

    Thanks for the reply.

    #344291 Reply

    Unknown Author
    Participant

    A moose bit my sister once…

    http://www.smouse.force9.co.uk/monty.htm

    -1TC

    #344300 Reply

    Bestmoose
    Participant

    Hilarious, -1TC
    3:)) ROFLHAAF (Rollin’ on floor hitting antlers against furniture)
    I love Monty, thanks for that precious link.

    Knowing, that you are already a ‘Big Fish’ 😉 in the Pond of App-developers, i humbly ask you: Do you have a solution to my coding problem.

    This coming from a real Gentlemoose 3;)

    Thanks for any reply.

    #344319 Reply

    Hi Bestmoose,

    The best approach is instead of bind your RunJS action to an app specific behavior/function consider calling a dispatch function. Then at runtime the dispatch function applies whatever app specific logic to determine the function to call. For example you can have it use something like js apply or eval or whatever dynamic function calling mechanism you choose.

    #344326 Reply

    Bestmoose
    Participant

    Hi Octavio,

    thanks for your support. It was eye-opening and I already worked it out.
    Keep on the good work. 3;)

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Replace the "Run JavaScript" code of a button

You must be logged in to post in the forum log in