modal dialog - Jquery Traversing -


I am using JQuery to show a modal dialog box. In the dialog box there is File Upload Control and Upload Button. In addition there are two buttons to save and cancel in.

I need to control file uploads essentially. I have to cross the file control and get the path by using $ (this) I'm able. Parent (). siblings (). Children () Get (1) .value; And display an error message on the click of the upload button. But I want to display the same error to save the button.

Need help in saving the button as I have created a button with the dialog box

  $ ("#dialog"). Dialog ({bgiframe: true, autoOpen: false, height: 500, width: 600, modal: true, button: {Cancel: jobs} {$ (this) .dialog ('close');} 'Save' : Function () {}}});    

From your code example it looks like inside this Cancel and Save Handlers is the #dialog element, so you can go for all children there. Instead it would be more robust to use a selector instead of a traversal. $ (this) .find (': file'). Val () should work.

Using selectors will make your code even more strong because it will continue to work even if you add additional elements in your dialog as some commentators have pointed out, giving file upload control a unique ID It will be easy to choose it with the selector. If you need the code to work for multiple dialog boxes with different IDs for the upload field, then you can use a class or other specific selectors in a specific context, such as the selector mentioned above. Find Combined with the method.

We may need a bit more context to help you, like what the content of the # dialog element is, perhaps to mention the jQuery plugin that defines the .dialog method, it will be useful.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -