0

Im following a example where they mentioned Ive to insert

$('[data-role="button"]').button();

to add the button dynamically in a proper way. But it shows

button.(..) is not a function, error.

HTML

<div data-role="page" id="page">

        <div data-role=header>

            <h1>Home</h1>

        </div>

        <div data-role="content" style="padding: 15px">

            <ul data-role="listview" id="listview" data-inset="true" data-filter="true">
                <li data-role="list-divider" id="divider">Available Devices</li>

            </ul>


        </div>
        <div data-role="footer" data-position="fixed" id="footer">
            <h3>Footer</h3>
        </div>
    </div>

Javascript function:

 function displayFeeds(items){
        var ul = $('#listview');
        for (var i = 0; i < items.length; i++) {
             var li = $('<li/>').html(items[i].DeviceNames);
             li.append($('<li/>').html(items[i].DeviceQuantity));



            li .append('<a data-role="button" data-theme="b" data-icon="plus" data-iconpos="right">Save</a>');
             // Enhance new button element
            li.append($('<hr>')); 
             ul.append(li); 

       }
        $('[data-role="button"]').button();
    }

What should I do here Or what am I doing wrong?

1
  • works fine. What version of jq and jqm are you using? Commented Sep 17, 2013 at 16:31

1 Answer 1

1

I had same problem.

Don't put $('[data-role="button"]').button();

Put ul.parent().trigger( 'create' ); at end of your for loop.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.