Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 31, 2012 04:04 AM by ignatandrei
Member
2 Points
38 Posts
Mar 30, 2012 11:38 AM|LINK
How can i add and remove partial views dynamicaly ?.
If i am click on a link add new , it should create a partial view inside <div id="items"></div> and
again if i click it will add another partial view to div like this i can able to create any no of partial divs inside the same page .
And if i click on submit button of the partial view i want to remove that from the page
(If i add 4 partial view P1,P2,P3,P4 and if i press submit button on P3 , then i need only remaining 3 partial view P1,P2,P4 on the page)
So how can i add and remove partialviews dynamically?
All-Star
24675 Points
4250 Posts
Mar 30, 2012 12:13 PM|LINK
Use jQuery to call an action via AJAX. The action should return a partial view. As for removing just remove any html from the container div
134521 Points
21576 Posts
Moderator
MVP
Mar 30, 2012 12:39 PM|LINK
Please see http://bit.ly/mvc_ajax_jquery
36648 Points
5434 Posts
Mar 30, 2012 01:42 PM|LINK
if you don't use ajax, then use this cool feature in languges called a for loop. keep the count of partials in a hidden field, and use a submit button (not link which woudl require javascript to post) to add.
@for (Model.CurrentIndex = 0; Model.CurrentIndex < Model.MaxPartials; ++ Model.MaxPartials) { @Html.Partial("thepartial") }
note: the parial shoud use the CurrentIndex:
@Html.TextboxFor(m=>m.field[m.CurrentIndex])
Mar 31, 2012 03:59 AM|LINK
can anyone posts some working links (to add via jquery) and to remove the div once i post the partial view
Mar 31, 2012 04:04 AM|LINK
mMATHAI can anyone posts some working links (to add via jquery) and to remove the div once i post the partial view
Did you look at tutorial and code source from
http://bit.ly/mvc_ajax_jquery
?
mMATHAI
Member
2 Points
38 Posts
Add and remove partial views
Mar 30, 2012 11:38 AM|LINK
How can i add and remove partial views dynamicaly ?.
If i am click on a link add new , it should create a partial view inside <div id="items"></div> and
again if i click it will add another partial view to div like this i can able to create any no of partial divs inside the same page .
And if i click on submit button of the partial view i want to remove that from the page
(If i add 4 partial view P1,P2,P3,P4 and if i press submit button on P3 , then i need only remaining 3 partial view P1,P2,P4 on the page)
So how can i add and remove partialviews dynamically?
raduenuca
All-Star
24675 Points
4250 Posts
Re: Add and remove partial views
Mar 30, 2012 12:13 PM|LINK
Use jQuery to call an action via AJAX. The action should return a partial view. As for removing just remove any html from the container div
Radu Enuca | Blog
ignatandrei
All-Star
134521 Points
21576 Posts
Moderator
MVP
Re: Add and remove partial views
Mar 30, 2012 12:39 PM|LINK
Please see http://bit.ly/mvc_ajax_jquery
bruce (sqlwo...
All-Star
36648 Points
5434 Posts
Re: Add and remove partial views
Mar 30, 2012 01:42 PM|LINK
if you don't use ajax, then use this cool feature in languges called a for loop. keep the count of partials in a hidden field, and use a submit button (not link which woudl require javascript to post) to add.
@for (Model.CurrentIndex = 0; Model.CurrentIndex < Model.MaxPartials; ++ Model.MaxPartials)
{
@Html.Partial("thepartial")
}
note: the parial shoud use the CurrentIndex:
@Html.TextboxFor(m=>m.field[m.CurrentIndex])
mMATHAI
Member
2 Points
38 Posts
Re: Add and remove partial views
Mar 31, 2012 03:59 AM|LINK
can anyone posts some working links (to add via jquery) and to remove the div once i post the partial view
ignatandrei
All-Star
134521 Points
21576 Posts
Moderator
MVP
Re: Add and remove partial views
Mar 31, 2012 04:04 AM|LINK
Did you look at tutorial and code source from
http://bit.ly/mvc_ajax_jquery
?