SpeekaDievs
SpeekaDievs

Reputation: 322

Append string to jquery-ui-dialog title

So basically i need to know how i can append a string to a dialog title.

for example the string is foo.

and if I run

$("#dialogid").dialog("option", "title", "bar")

in the js console, the title should be foobar.

EDIT:

basically this line of code shouldn't change. if i run specifically this line of code, the title will change to foobar

EDIT2:

So i've come up with a solution to my problem, but still i have no idea how could i make it so it would happend at once, not after 10 ms

$(function () {
    $("#dialogid").dialog({})
    $("#dialogid").dialog('option', 'title', 'bar');

    setInterval(function(){ 

        var title123 = $("#dialogid").dialog( "option", "title" );
        var n = title123.indexOf("foo");
        if(n < 0) {
            $("#dialogid").dialog( "option", "title", "foo" + title123);
        }

    }, 10);
});

Upvotes: 0

Views: 298

Answers (2)

Thomas
Thomas

Reputation: 34188

here is jsfiddle link http://jsfiddle.net/tridip/rxV8R/18/

$(function () {
    $("#dialog").dialog({})
    //init title with text
    $("#dialog").dialog('option', 'title', 'Foo');

    //later change the text
    $("#dialog").dialog('option', 'title', $("#dialog").dialog('option', 'title')+' Bar');
});

if any area is not clear then aks me please.

Upvotes: 1

Mani5556
Mani5556

Reputation: 403

This should work (assuming that you want to append to the pre-existing dialog title):

var existingTitle = $("#dialogid").dialog("option", "title"); 
$("#dialogid").dialog( "option", existingTitle  + "bar" );

Upvotes: 1

Related Questions