facebook

action implementation compat issue with 1.5

💡
Our Forums Have Moved

For help with installation, bugs reports or feature requests, please head over to our new forums.
Genuitec Community on GitHub

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

    SonamGyato
    Member

    Wayne,

    If you remember, I dynamically create a list and intercept list-item clicks.

    for each of the listitems, i used to add a HREF attribute and pass it to
    one of my javascript functions.

    href=”javascript:onListSelect(‘ + i + ‘)

    where i is the index into the list.

    In 1.5, it seems to have changed.

    <li id=”m1-app-listItem1″ class=”m1-first m1-last m1-clickable m1-highlight”
    data-action-click-id=”action18″>

    in mobi – i set the action to a javascript function.

    How can I get my functionality back.

    #324589

    support-michael
    Keymaster

    @everest

    I am updating the custom-list example for 1.5 compatibility. Interesting! Did we provide direction for using the href attribute in such a manner? I thought we obsolesced this approach in favor of actions quite some time ago. I think there may be an alt approach. I need to check with lead dev first. Will get confirmation on monday.

    #324601

    SonamGyato
    Member

    Maybe – but it was working pre 1.5.

    The big issue is that the list-item entry that was clicked on
    needs to be passed to the callback function.

    #324614

    support-michael
    Keymaster

    @everest

    As you have identified the href attribute is no longer generated in favor of a different internal implementation for actions.

    Instead of generating the HTML <li> attribtue:

    href="javascript:onListSelect(' + i + ') 

    consider replacing the href with an attribute that contains the list-item’s index such as

    data-list-index=" + i + "

    Then in the RunJS action for the list-items using a jquery snippet like this to look up the data-list-index attribute:

    
      index = $(event.srcElement).attr('data-list-index');
    
    #324625

    SonamGyato
    Member

    For others trying to get it working w/ 1.5.

    Another change is that the element id

    m1-???- (where ??? is your mobi page name)

    has been renamed

    m1-???-panel1-scroller

    Also, the “event” object in the previous response is
    a global variable.

    #324627

    SonamGyato
    Member

    I think this work fine…just small edits here and there.

    One “problem” is that the action?? numbers seem to change everytime
    i edit a mobi file.

    the problem is that these numbers are hardcoded in my custom.js file.

    as in similar to

    ‘<li id=”m1-legs-listItem1″ class=”‘ + cssClassList + ‘” data-list-index=”‘ + i + ‘” data-action-click-id=”action18″‘ + ‘>’ …

    so i have to go back and find the proper action?? from the app.html file and then change it in my custom.js file.

    it would be nice for me not to do this manual and error prone process.

    #324633

    support-michael
    Keymaster

    @everest

    A quick fix is to move your js code from the Run JS action editor into a custom function in your _custom.js file. Then in your Run JS action have a 1 liner that calls your function in _custom.js. This is how I almost always impl my javascript functionality as it is much easier to use the Debugger on _custom.js file, I can use much better web editor if I choose and my _custom.js file is never overwritten.

    #324636

    SonamGyato
    Member

    It’s manageable because once I stop editing the mobi files – the
    action?? don’t change.

    A real frustrating bug with the emulator tool is – when i open
    the storage Database editor and type in a SELECT query –
    the tool crashes at SE.

    I’ve reported this before – it’s crashing when it tries to auto-complete
    the word.

    Just turn the feature off!!!

    Problem solved.

    The whole dev environment gets frozen and have to restart everything.

    #324638

    support-michael
    Keymaster

    >I’ve reported this before – it’s crashing when it tries to auto-complete
    the word.

    I opened a bug on previous report that running sql queries is slow. I don’t recall “crash” discussion (maybe my oversight) as that is a much different problem and gets P1 attention. Can you provide me a few more details about the structure of your DB?

    I ran the StickyNotes demo provided in the Test Center and inspect its Local Storage sql db. It does not crash in my simple case. See screenshot below.
    See attachment db-inspector.png

    Attachments:
    You must be logged in to view attached files.
    #324640

    SonamGyato
    Member

    it doesn’t happen always – but definitely by the 2nd or 3rd try.

    i’ve got a single table.

    select * from Owner;

    if you can provide an option to disable this auto-complete feature –
    maybe that’ll help me.

Viewing 10 posts - 1 through 10 (of 10 total)
Reply To: action implementation compat issue with 1.5

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