Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
wantoun
Posts: 165
Registered: ‎10-04-2010
My Device: P'9982 & Z10
My Carrier: alfa Lebanon

Re: Context Menu - Modify List Element

the item.setAttribute function ads the double quote ", this is what I end up with if I swtich the quotes:

 

data-webworks-context="{"id":"1", "type":"MyContext", "header":"The Author", "subheader":"Mr. William Goldman"}"

 

Wadi
Please use plain text.
BlackBerry Development Advisor (Retired)
erikjohnzon
Posts: 245
Registered: ‎09-21-2012
My Device: Q10
My Carrier: Virgin

Re: Context Menu - Modify List Element

That looks fine to me. Is it possible for you to send me an email to have a look? bar or zip?

 

erjohnson@blackberry.com

@erikjohnzon
erjohnson@blackberry.com
Please use plain text.
Developer
wantoun
Posts: 165
Registered: ‎10-04-2010
My Device: P'9982 & Z10
My Carrier: alfa Lebanon

Re: Context Menu - Modify List Element

alright, I'll email you my code then.

Thanks!
Wadi
Please use plain text.
BlackBerry Development Advisor (Retired)
erikjohnzon
Posts: 245
Registered: ‎09-21-2012
My Device: Q10
My Carrier: Virgin

Re: Context Menu - Modify List Element

Change "MyContext" -> "myContext" you define it using "myContext" but then add items to the context "MyContext".

 

Give that a shot it worked for me and showed me the toast properly :smileyhappy:.

@erikjohnzon
erjohnson@blackberry.com
Please use plain text.
Developer
wantoun
Posts: 165
Registered: ‎10-04-2010
My Device: P'9982 & Z10
My Carrier: alfa Lebanon

Re: Context Menu - Modify List Element

ok that wasn't very smart! :smileytongue: Thanks

 

blackberry.ui.contextmenu.addItem(contexts, myItem, function(Id) {
        var selectedItem,
            context = document.getElementById(Id);
        console.log(Id);
        console.log(context);

        selectedItem  = context.menu.selected;
        if (selectedItem) {
            toast(selectedItem);
        }
    });

 Id is being returned alright, but I still can't get the element's ID because context is null.

Wadi
Please use plain text.
BlackBerry Development Advisor (Retired)
erikjohnzon
Posts: 245
Registered: ‎09-21-2012
My Device: Q10
My Carrier: Virgin

Re: Context Menu - Modify List Element

You are expecting the dom to find your element by id="1" but you have not given your elements and #id reference tag. You should add it inside your createReminderItem(title, label, status, id) function:

item.id = id;
// then pass it in
....'{ "id":' + id + ' .....}'

This will give you a dynamic ID you can look up in the DOM.

@erikjohnzon
erjohnson@blackberry.com
Please use plain text.
Developer
wantoun
Posts: 165
Registered: ‎10-04-2010
My Device: P'9982 & Z10
My Carrier: alfa Lebanon

Re: Context Menu - Modify List Element

Thank you so much!
Wadi
Please use plain text.
Regular Contributor
andreyavram
Posts: 76
Registered: ‎06-02-2012
My Device: Playbook, BB10
My Carrier: Orange

Re: Context Menu - Modify List Element

Very good answers, @erikjohnzon , they helped me a lot!

 

Now, what about some events? I want to grey out the element selected, I can do that using the id field, but I can't figure out how to detect the closing of the crosscut menu, so I can remove the grey class from my element.

The events proposed here https://github.com/blackberry-webworks/BB10-Webworks-API/issues/37 don't seem to be fully implemented, unfortunately.

 

Thanks!

Please use plain text.