×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Jun 2010
    Posts
    161

    Change onclick-Event on the fly?

    Hi,

    is there a way to change the onclick event (in my casee of an image) on the fly?

    I have something like a flickr viewer and show a grid of images. When clicked, the image opens in a view where it is big. It's loaded dynamically only if clicked. Now I want to change the onclick of the grid-image so that instead of running the showFullImage("someid") function is just runs the, hopefully now round-trip-free, mwl-command >> mwl.setGroupTarget('#pages', '#pageFull-someid', 'show', 'hide'); <<.
    I tried doing it via
    document.getElementById("gridImage-someid").onclick = "mwl.setGroupTarget('#pages', '#pageFull-someid', 'show', 'hide');";

    but it doesn't work when I try it on the phone or as cloud preview.

    Ideas?

  2. #2
    Registered User
    Join Date
    Mar 2013
    Location
    United Kingdom
    Posts
    161

    Re: Change onclick-Event on the fly?

    Could you not use some sort of boolean flag within the onclick function? ie, something like this?

    var showFullImage = true;

    function onImageClicked() {
    if (showFullImage == true) {
    showFullImage = false;
    // do other stuff
    } else {
    mwl.setGroupTarget('#pages', '#pageFull-someid', 'show', 'hide');
    }
    }

  3. #3
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,777

    Re: Change onclick-Event on the fly?

    Quote Originally Posted by lorion84 View Post
    I tried doing it via
    document.getElementById("gridImage-someid").onclick = "mwl.setGroupTarget('#pages', '#pageFull-someid', 'show', 'hide');";

    but it doesn't work when I try it on the phone or as cloud preview.

    Ideas?
    Try setAttribute as shown below,

    Code:
    document.getElementById("gridImage-someid").setAttribute('onclick', "mwl.setGroupTarget('#pages', '#pageFull-someid', 'show', 'hide')");
    and yes, the click wouldn't cost you a round trip since mwl functions are executed locally.
    Pankaj Nathani
    www.croozeus.com

  4. #4
    Regular Contributor
    Join Date
    Jun 2010
    Posts
    161

    Re: Change onclick-Event on the fly?

    Thank you, it worked... after finding some annoying additional quotation-error...

Similar Threads

  1. Cluster onclick event
    By Lundquist in forum [Archived] Maps API for Javascript
    Replies: 3
    Last Post: 2013-04-26, 10:59
  2. How to change the onclick event for the embeded media player in nokia6700
    By jornel in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2009-12-08, 10:15
  3. onClick getting wrong event
    By awysocki in forum Symbian Web Runtime
    Replies: 0
    Last Post: 2009-09-01, 22:55
  4. ECMAScript/onclick event and nokia 6233
    By sleepwlkr in forum Browsing and Mark-ups
    Replies: 1
    Last Post: 2007-09-21, 22:45
  5. XHTML+ECMAScript Onclick Change Colour code review
    By adamsimmonds in forum Browsing and Mark-ups
    Replies: 5
    Last Post: 2007-08-24, 06:24

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •