Question

The below code is for show image, price, description in dialog box. I want to show the image title in the dialog title bar. I tried as I can, but no luck. Can anyone help me ?

$(".dialogify").bind("click", function(e) {
    e.preventDefault();

    tit=$("#dialog").html("<img src='" + $(this).next().find('img').attr('title')+"'/>");

    $("#dialog").html("<img src='" + $(this).next().find('img').attr('src') + "' width='150' + height='150'>"+'<h2>'+ $(this).next().find('img').attr('title')+'</h2>'+"<label>"+ $(this).next().find('img').attr('price')+"</label>"+"<label>"+$(this).next().find('img').attr('desc')+"</label>"+"<input type='button' value='@(Model.ProductPrice.AvailableForPreOrder ? T("ShoppingCart.PreOrder") : T("ShoppingCart.AddToCart"))' class='button-2 product-box-add-to-cart-button' onclick='AjaxCart.addproducttocart('@addtocartlink '); return false;' />")

    $("#dialog").dialog("option", "position", {
        modal:"true",
        my: "center",
        at: "center",
        title:"tit",
        of: window
    });
    if ($("#dialog").dialog("isOpen") == false) {
        $("#dialog").dialog("open");
    }
});
Was it helpful?

Solution

You can see title using option like

$("selector").dialog('option', 'title', 'New Title');

So you use following code

$("#dialog").dialog('option', 'title', $(this).next().find('img').attr('title'));

EDIT

//Fetch title here
tit=$(this).next().find('img').attr('title');

$("#dialog").dialog("option", "position", {
    modal:"true",
    my: "center",
    at: "center",
    title: tit, //tit instead of 'tit'
    of: window
});

OTHER TIPS

Try:

title: tit

instead of:

title:"tit"

How about this

 $("#dialog").dialog( {
        modal:"true",
        my: "center",
        at: "center",
        title:"tit",
        of: window
    });

Remove params "option", "position"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top