I have input with either some given or empty “data-file”:
<input type="text" value="path/to/file.gif" name="some_file" data-fileid=".selector" data-file="/path/to/file.gif">
The cancel:
<button class="cancel" type="button" accesskey="c">Cancel</button>
I am manipulating the textfield to insert images which is fine, but when it comes to manipulating via data attributes, the button do not work:
var inputBg = $('fieldset:visible input[name*="file"]');
var dataOld = inputBg.data('file');
var dataSel = inputBg.data('fileid');
$('.cancel').click(function() {
$(inputBg).val(dataOld); // revert to old stored value if any
$(dataSel).css('background', 'none'); // remove background from .selector
});
I am using a jquery.ui.tabs, thats why I have: “fieldset:visible”.
But the cancel button do not work. Any idea whats missing?
Thanks
UPDATE:
Problem identified, I have to do binding to ui.tabs, but still looking for suggestions on other route, because my binding is not bullet-proof. I have to do duplication 🙁
I also have to change relative path to absolute path on “data-file”.
I have to do the buttons inside and outside ui.tabs. Regarding duplication I can create another function that serves for any call.
I will change this as an answer if any better reply. Thanks to all