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

[Solved] Change or Reset ContentUrl and Cancel onSelect

3 Answers 99 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nick
Top achievements
Rank 1
Nick asked on 17 Aug 2011, 01:09 PM
I have 2 tabs in a tabstrip control.  The first tab is used to create a user and has fields for Username, password...
The second tab is disabled using .Enabled(ViewBag.Id > 0) where ViewBag.Id is the userId. 
The second tab has  .LoadContentFrom("UserActivity", "User", new {id=ViewBag.Id}).
When Save is clicked on the first tab I execute an ajax post and
1) enable the second tab 
2) try and change the contentUrl to include the new value.
 
I need to reset the contentUrl of the second tab to include that value (i.e. /User/UserActivity/(new user id)) so that when the second tab is clicked my controller is passed the correct user id instead of -1.

Is this possible?  Any other suggestions?

I've tried to reload the content onSelect, but the action is executed twice. Is there a way to prevent the action from being called while still allowing the tab to be selected and shown?  I've tried e.preventDefault() but that stops the tab from being shown.

Thanks,


3 Answers, 1 is accepted

Sort by
0
Nick
Top achievements
Rank 1
answered on 17 Aug 2011, 05:10 PM

So it seems the second tab is only loaded twice the first time it is selected. Afterwards, clicking on a tab will cause it to be reloaded via OnSelect.
To get around this issue, in the OnSelect handler I called
 

e.preventDefault();

e.stopPropagation();

then i rebuild the url with the new Id (i changed User/UserActivity/-1 to User/UserActivity/34(new user id))
then inside $.get i select the current tab item.

 

$.get(contentUrl,

 

function (data) {

$(e.contentElement).html(data);

 

tabstrip.select($item);

});

 

 

0
leblanc
Top achievements
Rank 1
answered on 01 Mar 2013, 09:06 PM
@Telerik is there anyway to attach to a ContentLoading event so we can cancel the first load - until we have time to update the url at runtime?


also related to: http://www.telerik.com/community/forums/aspnet-mvc/grid/popup-editor-bind-model-to-loadcontentfrom.aspx

0
Daniel
Telerik team
answered on 06 Mar 2013, 10:27 PM
Hello,

Loading the content can be prevented by calling the event argument preventDefault method in the OnSelect event but the event will not be triggered when the SelectedIndex is set trough the configuration. The initial index should be removed in order to replace the URL.

Kind regards,
Daniel
the Telerik team
Check out the successor of Telerik MVC Extensions - Kendo UI for ASP.NET MVC - and deem it for new ASP.NET MVC development.
Tags
TabStrip
Asked by
Nick
Top achievements
Rank 1
Answers by
Nick
Top achievements
Rank 1
leblanc
Top achievements
Rank 1
Daniel
Telerik team
Share this question
or