This is a migrated thread and some comments may be shown as answers.

Dynamic Action Sheet

4 Answers 186 Views
ActionSheet
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 28 Dec 2012, 03:58 PM
I am trying to get an action sheet to modify itself depending on which screen it is on.  Basically in my scenario I have an button on my navbar that I wish to be a context sensitive menu.  I have a jsbin to show an example of what I am trying here ... http://jsbin.com/ehicof/5/edit.

If you hit the 'logout' button on the top right initially the action sheet looks fine, when you go to the search tab and then to 'search 1' I change the action sheet contents to have a 'search 1' button, however the action sheet doesn't grow (and thus the 'cancel' button is not visible).  I have tried re-initializing the action sheet to no avail (using kendo.mobile.init), perhaps I am using it wrong.  Am I taking the wrong approach here?  Would I be better off making multiple action sheets and then changing the link on the navbar to the appropriate one?

4 Answers, 1 is accepted

Sort by
0
Accepted
Alexander Valchev
Telerik team
answered on 28 Dec 2012, 04:35 PM
Hello David,

Replacing the html of the widget at runtime is not supported. Instead please destroy the widget, change the mark-up and init it again.
function search1Show(){
    $("#userActions").data("kendoMobileActionSheet").destroy();
    $("#userActions").html('<li class="km-actionsheet-title">Select Action</li> <li><a href="#" data-action="search1">search1</li></a><li><a href="#" data-action="changeProfile">Change Profile</a></li><li><a href="#" data-action="Logout">Logout</a></li>');
    kendo.init($("#userActions"), kendo.mobile.ui);
}

Please note that destroy method is available in Q3 release. You have to upgrade to version 2012.3.1114 or later.
Here is a link to the updated example: http://jsbin.com/ehicof/8/edit

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
David
Top achievements
Rank 1
answered on 28 Dec 2012, 04:38 PM
Works great, thanks for your help Alexander.
  -David
0
David
Top achievements
Rank 1
answered on 28 Dec 2012, 04:42 PM
Quick followup, while this technique works, is this the 'appropriate' way to handle this scenario?  Am I better off dynamically building the list for each view or is it generally a better idea to have multiple action sheets?
0
Alexander Valchev
Telerik team
answered on 28 Dec 2012, 04:48 PM
Hello David,

The answer of this questions depends on the requirements of your project. Generally speaking I would recommend to create separate action sheets.
Please test the solutions and choose the one that best suits to your case.

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
ActionSheet
Asked by
David
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
David
Top achievements
Rank 1
Share this question
or