DmitryEfimenko / TwitterBootstrapMvc

Fluent implementation of ASP.NET-MVC HTML helpers for Twitter Bootstrap.
Apache License 2.0
224 stars 79 forks source link

Data() #248

Closed matt411 closed 10 years ago

matt411 commented 10 years ago

I am trying to accept partial delivery of an invoice item if the invoice item had a quantity of 5 and only 2 are delivered I need accept specify the quantity of 2. I used a button to render a modal but I need to get the InvoceItemId from the button to the RenderPartial controller. So that's my question, how do I pass an Id from a button using Data(new{object}) to a Partial View Result in a modal? Please Note: the button below is part of a table created by a for loop.I just need to get the

@Html.Bootstrap().Button()
    .Text("Accept Inventory")
    .TriggerModal("modalId2")
    .Class("btn btn-default")
    .Data(new 
    { 
        shoeOrderItemId = Model.ShoeOrderItemList[i].ShoeOrderItemId 
    })

How do I pass the ShoeOrderItemId from Button.Data() to the controller to Render the Partial View Result (not pictured)

@using (var modal = Html.Bootstrap().Begin(new Modal().Id("modalI2").Closeable()))
{
    @modal.Header("Accept Purchase Order Items")
    using (modal.BeginBody())
    {
        @Html.Partial("AcceptPartialShoeDelivery")  
    }
    using (modal.BeginFooter())
    {

        @Ajax.ActionLink("Accept Partial", "AcceptPartialShoeDelivery","ShoeOrder",
        new AjaxOptions
        {
            HttpMethod = "GET",
            UpdateTargetId = "replaceMe"

        }, new { @class = "btn btn-danger" })
    }
}
DmitryEfimenko commented 10 years ago

This is not really a BMVC question, but rather a general programming question. A better place for it would be on StackOverflow.

However, it seems that you'll need to use JQuery to achieve this. You would want to bind the button click event to a function that would look at the data attribute's value and put it in the partial view however you need it to be done.

matt411 commented 10 years ago

I can do that. TBMVC is just cleaner. Thanks

On Tue, Feb 18, 2014 at 4:08 PM, Dmitry A. Efimenko < notifications@github.com> wrote:

This is not really a BMVC question, but rather a general programming question. A better place for it would be on StackOverflow.

However, it seems that you'll need to use JQuery to achieve this. You would want to bind the button click event to a function that would look at the data attribute's value and put it in the partial view however you need it to be done.

Reply to this email directly or view it on GitHubhttps://github.com/DmitryEfimenko/TwitterBootstrapMvc/issues/248#issuecomment-35434186 .

johnkattenhorn commented 10 years ago

I'd second this kind of feature, the comment's right it's easy to do via jQuery but it would be much nicer to do it all through the TBMVC declaration if possible.

Gotta say though, the more I've used the excellent project the more I love it, it's just so fast to get a reasonable screen out to the users for them to kick the tyres.

matt411 commented 10 years ago

The biggest reason IMO would be to make the code more maintainable. TBMVC makes the use jQuery almost nonexistent in many instances. Then all of the sudden there is a random view with jQuery.

I will say other than the Data() feature TBMVC is a great product that overall makes code so much easier to read. Expanding the scope would just add to readability.

On Apr 2, 2014, at 7:53 AM, johnkattenhorn notifications@github.com wrote:

I'd second this kind of feature, the comment's right it's easy to do via jQuery but it would be much nicer to do it all through the TBMVC declaration if possible.

Gotta say though, the more I've used the excellent project the more I love it, it's just so fast to get a reasonable screen out to the users for them to kick the tyres.

— Reply to this email directly or view it on GitHub.