I have a custom module with differents forms and on one of these forms i want to submit and open the result on a new tab. I found a way to do this on this link : custom form submit in a new browser tab
it works great but instead i need to make a js file to do the same thing.
If it works with the target attributes (link above) directly put in my form why make the same thing in a js file ? i suppose that i will have to use a js file, because with the target attributes it does not work, a new tab does not open when i clicked on a modal button (using ctools modal form).
So my problem is the following: when i make a js file and put this code
(function ($) {
Drupal.behaviors.multi_example = {
attach: function(context, settings) {
$('#pv-button').attr('target', '_blank');
}
};
})(jQuery);
It does anything ! On my js file, my id button works properly, i have tested it with a simple alert:
.click(function(){
alert("Hello World");
}
and it works. I've also tested with window.open('','_blank')
and a new tab open. So i think there is a problem with the .attr() function. I've passed a long time to search a solution on "google" but nothing... i need some help please.
PS: I want to precise that i have used all these codes (code above) on a normal node, not on a modal.
I'm using Drupal 7.50, jQuery 1.10.2, PHP 5.6.19