How can i achieve this using jquery function when clicking on the tab?
Add a function for this click. In the function, make an ajax request (http://bit.ly/mvc_ajax_jquery )and retrieve data as html ( or as variable, since you are using knockout).
Do i need to be using partialviews for this? each tab is a new view so do not require that work
I tried to do an ajax call using the @url.action helper within the key url for $ajax function but this kept duplicating all items on the page everytime i clicked. it seemed the tab clicked was loading in the same page but not clearing??
how can i call the @url.action method within javascript to render a new view
each tab is a new view so do not require that work
Do not ? Please explain
tejp
I tried to do an ajax call using the @url.action helper within the key url for $ajax function but this kept duplicating all items on the page everytime i clicked. it seemed the tab clicked was loading in the same page but not clearing??
That's your javascript code that it's not clearing.
tejp
how can i call the @url.action method within javascript to render a new view
Did you look at my link http://bit.ly/mvc_ajax_jquery ?
each tab is a new view so do not require that work
Sorry what i meant was that each tab item has its own view and controller. So what i was asking was if them views need to be rendered as partial views rather than full views.
Also when returning the view how can i get the knockout.js to render rather than html?
tejp
Member
113 Points
304 Posts
Load view using jquery from _layouts.cshtml
May 02, 2012 09:04 AM|LINK
Hi
I have some tabs on my _layouts.cshtml page as they need to be there throughout the site.
I have used foundation zurb tabs. Also using knockout to bind to the tabs which are created at runtime lazy loading.
My next step is when clicking on the tab i need to load the relevant view e.g. contacts view.
How can i achieve this using jquery function when clicking on the tab? I looked at $.load but it refers to the div that needs to be rendered.
Was wondering would i need to wrap the @Renderbody within a div so that the view is rendered within the div item?
any assistance would be great
ignatandrei
All-Star
135087 Points
21669 Posts
Moderator
MVP
Re: Load view using jquery from _layouts.cshtml
May 02, 2012 09:26 AM|LINK
Add a function for this click. In the function, make an ajax request (http://bit.ly/mvc_ajax_jquery )and retrieve data as html ( or as variable, since you are using knockout).
tejp
Member
113 Points
304 Posts
Re: Load view using jquery from _layouts.cshtml
May 03, 2012 09:15 PM|LINK
Hi
Do i need to be using partialviews for this? each tab is a new view so do not require that work
I tried to do an ajax call using the @url.action helper within the key url for $ajax function but this kept duplicating all items on the page everytime i clicked. it seemed the tab clicked was loading in the same page but not clearing??
how can i call the @url.action method within javascript to render a new view
ignatandrei
All-Star
135087 Points
21669 Posts
Moderator
MVP
Re: Load view using jquery from _layouts.cshtml
May 04, 2012 03:44 AM|LINK
That's your javascript code that it's not clearing.
Did you look at my link http://bit.ly/mvc_ajax_jquery ?
tejp
Member
113 Points
304 Posts
Re: Load view using jquery from _layouts.cshtml
May 04, 2012 09:14 AM|LINK
Sorry what i meant was that each tab item has its own view and controller. So what i was asking was if them views need to be rendered as partial views rather than full views.
Also when returning the view how can i get the knockout.js to render rather than html?
have you had a go at this?
cheers
ignatandrei
All-Star
135087 Points
21669 Posts
Moderator
MVP
Re: Load view using jquery from _layouts.cshtml
May 04, 2012 09:37 AM|LINK
Does not matter.
Return data, not html, and send to knockout.