0
I made an html form, put it on a platform that loads this form. However, there are platform buttons that perform functions in the form (such as sending the form, saving and so on). Then I discovered that I can manipulate these platform buttons with code inside the form using this:
window.parent
for example, I can drop an Alert when a certain platform button is pressed with that code:
window.parent.$(".fixedTopBar").find("button").on("click", function(ev) { alert("OK"); });
Ai, I have this button (which logically I can not change it, because it is the platform):
<button type="button" class="btn btn-primary" data-send="">Enviar</button>
And I want to run a script when it’s pressed... As I have other buttons on the page, I decided to capture the "on(click)" button with the data-send (since it is unique in this).
I tried codes like:
window.parent.$('[data-send]').on("click", function(ev) { alert("OK"); );
window.parent.$('button[data-send]').on("click", function(ev) { alert("OK"); );
window.parent.$('button').data("send").on("click", function(ev) { alert("OK"); });
But it didn’t work. I don’t understand much about the date attribute... It must be from the difficulty of understanding how to use it.
If it’s better, I drew it like this: [Red] Environment [Blue] form [Green Arrow] Button I want to capture the click
Is that button present when the page loads? Test
$(document).on("click", '[data-send]', function(ev) { alert("OK"); );
– Sergio
Actually, I didn’t post the whole code... It’s a window that gets outside the document... I use a: window.parent. before.
– CarlosM
As if the widget is outside the document?
– Jéf Bueno
This is inside a platform that a window loads an external document so that button I want to capture is in the window, not in the document... I’ve done tests like: window.parent. $("#workflowActions"). on("click", Function(Ev) { va(Ev); }); and it works...
– CarlosM
Solved! Added in question and here:
window.parent.$("[data-send='']").on("click", function(ev) { validateForms(ev); });
– CarlosM
Do not post your solution by editing the question; for this there is the answer area. There are no problems in answering the question itself; in fact, this is quite common here, but try to structure it well, not just with a line of code, but with an explanation of why it didn’t work the way it was and why its code solved the problem. If you do not fully understand why the solution works and the others presented in the question does not, your problem has not yet been solved.
– Woss
Especially because his example of
$('button[data-send]')
should work. See here.– Woss