Open a JQueryUI Dialog and have it populate itself from DB
I have a list of companies and I want to be able to open a dialog to be able to edit their details. This opens the dial开发者_JS百科og:
$('#company_details').click(function() {
$('#dialog').dialog('open');
});
Only binds the dialog to the first instance of , not every one.
And then, how can I pass the dialog an ID so I can then run an AJAX query?
If you have more than one company, then you need some way to select each - like a button or an image. This button or image or other link could have it's own id. For example:
<tr>
<td>Company ABC</td>
<td><button class='details' id='12345'>Details</button></td>
</tr>
<tr>
<td>Company XYZ</td>
<td><button class='details' id='45454'>Details</button></td>
</tr>
Then your code would be:
$(".details").click(function(){
var id = $(this).attr("id");
--> insert what you want to do <---
}):
Not entirely sure what you mean, but try using a class selector instead of an id:
$('.company_details')
instead of
$('#company_details')
If that doesn't work could you update your question with the html you're using?
There are a few ways to pass in the id, check http://docs.jquery.com/Core and look for the data(name,value)
method. You can set the id in there then retrieve it when you need it later.
精彩评论