jquery mobile buttons not working when created dynamicaly - jquery-mobile

i m using jquery mobile ver. 1.3.0 i want to create a button from jquery from my js file and want to show that button on my page but its not working.
Here is my jquery code to dynamicaly generate button:
View
its only shows the text not the button.
i think its because of the fact that the button is generated dynamicaly so its is unable to found the css in js file.thats why its not showing on page.coz on my page all buttons are working properly.

After adding the button to the DOM,call trigger create method on the page to force JQM to reapply its styles.
$("#pageID").trigger("create");

Related

set programmatically focus when new content is loaded on iOS

I'm trying to set up automatically focus on first loaded article. (f.e. user clicks on the button "load more" and new articles are loaded).
My react implementation:
I'm using ref attribute in <Link> component, which is from react-router library and then I'm calling focus() method in lifecycle method componentDidMount().
It works on all devices except iOS. If I turn on voiceover on iphone and then on webpage I click on the button, it doesn't automatically focus on first loaded article). It works just with html anchor tag.
I read some articles before and it looks that it's not possible to do this in this way but only with firing some event f.e. click event.
Can someone confirm that it's not possible to solve it in this way or there is any workaround without using jquery ?

ios Cordova: tableview-like html

I currently focus on an iOS web app using Apache Cordova and JQuery Mobile.I want to implement a tableview-like style page (it is called listview in JQuery Mobile). I implement a initial list view in html and I'd like to: when I click the different rows, the html will send message to the iOS, and then I create a request with native code. After that, I return the successful result to js and js will update the list view which looks like you click a row in a tableview and a new page is pushed in.
The problem here is:
how to add the click event?
in the click event, how can I know which row is clicked?
how the tableview-like pushing animation is implemented when I use JQuery Mobile to update the list view?
I'm fresh to the web app and it costs several hours to implement dynamicly creating a list with the request result. And I totally do not know how to go further.
thanks for your help.
I. and II. Here's an example for your first and second question:
This is a code example:
$('ul.listview-example[data-role="listview"] li').bind('click',function(event, ui){
alert($(this).attr('id'))
});
First code line will bind a click event on every listview li element. $(this) is a selected li element.
If you are using never version of jQuery us .on( instead of .bind(, in older version you can also use .live( .
EDIT :
III. I think this should cover your third question: http://jsfiddle.net/Gajotres/YShLE/

next & previous button not working properly in jquery mobile

I m new to Jquery I have created example jquery mobile in this if back and login button is used once then next(>>) and prevoius(<<) button display the same page not that which is refferd using href tag. Before using Back button and login button it work fine afterusing those button it works abnormally.
edit and to view demo http://jsfiddle.net/khushbujoshi/JERG4/5/
DOM Element IDs are unique don't use them twice.
You don't need to do the page change on your own with jQuery. Let jQuery-mobile handle it.

jQuery UI autocomplete combobox in a modal dialog

I want to use a autocomplete combobox http://jqueryui.com/demos/autocomplete/#combobox within a modal dialog. However whenever I click on the down arrow (of the combobox) it causes a refresh that results in my modal window closing.
How do I stop the refresh from occuring? (I am still new to jQuery)
I am using UI 1.8 and jQuery 1.4.1.
The problem is discussed on the jQuery forum here:
http://forum.jquery.com/topic/autocomplete-combobox-problem-when-it-is-placed-inside-a-form-tag
They suggest several different ways of adjusting the source code of the autocomplete combo to fix it. The simplest one seems to be this:
Change the line that says
$("<button> </button>")
to
$("<button type=\"button\"> </button>")
this prevents the type="submit" from being inserted into the final button.
Ok I fixed my own problem by removing the form tag from around the combobox

How to open a html page as a popup with in the page (no new window opens) using Jquery

I am having the link button and when i clicked on the link button the popup will be open (with in the page itself like a modalpopup. now i have to get the popup feel using jquery and inside the div text should come from database.
How is it possible for getting the message from the backend.
means open a div in a modal popup feel using jquery
or opens the html page in a popup in the same window using jquery
Thanks and Regards
Vara Prasad.M
Take a look at the Facebox jQuery plugin. It does pretty much exactly what you're asking for. For example you can have a link like this to some remote page like so
text
then just call the facebox plugin when your content is loaded like so
jQuery(document).ready(function($) {
$('a[rel*=facebox]').facebox()
});
and your content will render in a modal window. You can also take a look at Fancybox or ThickBox which provide very similar functionality.
There are two steps to your problem:
Open a modal popup using jQuery
Fetch server side content and display it in the modal dialog
Use jQuery Dialog (http://docs.jquery.com/UI/Dialog) for popping open a modal dialog, and then use jQuery load (http://api.jquery.com/load/) for loading the content from the server.
The server page you call will make the database query and output the contents to the response buffer.

Resources