Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Boostrap - Get popover textarea and input value

I'm trying to get the input value inside a Bootstrap popover on submit, but i got a empty value.

<div class="popover-markup"> <a href="#" class="trigger">Popover link</a> 
    <div class="head hide">Lorem Ipsum</div>
    <div class="content hide">
        <div class="form-group">
            <input type="text" id="myinput" class="form-control" placeholder="Type something…">
        </div>
        <button type="submit" id="mysubmit" class="btn btn-default btn-block">Submit</button>
    </div>
    <div class="footer hide">test</div>
</div>

$('.popover-markup>.trigger').popover({
    html: true,
    title: 'Get value',
    content: function () {
        return $(this).parent().find('.content').html();
    }
});

$(document).on("click", "#mysubmit", function () {
    var inputval = $("#myinput").val();
    alert(inputval);
    return false;
});

http://jsfiddle.net/onigetoc/RvLrA/

like image 862
Gino Avatar asked Jan 21 '14 15:01

Gino


1 Answers

Try referencing it like this:

var inputval = $(".popover #myinput").val();
like image 65
Trevor Avatar answered Sep 18 '22 00:09

Trevor