user1683039
user1683039

Reputation: 75

Click event working fine in mozzila but not in chrome

I have one hidden file field and one browse button. When i click on browse button it will fire a click event which clicks on file field. My code is working fine in mozzila but not in chrome. Code is as follows :

 $("#upload, #browse_product_detail_file").bind({
    click: function(){
      $('#product_master_csv_file').trigger('click');
      return false;
     }
 });

I have tried the following also :-

 $("#upload, #browse_product_detail_file").bind(
    "click", function(){
      $('#product_master_csv_file').click();
      return false;         
 });

and

$("#upload, #browse_product_detail_file").click(function(){
      $('#product_master_csv_file').trigger('click');
      return false;
     }
 });

and

$("#upload, #browse_product_detail_file").live("click", function(){
      $('#product_master_csv_file').trigger('click');
      return false;
     }
 });

But this is working fine

$("#upload, #browse_product_detail_file").click(function(){
      alert("clicked");
     }
 });

Upvotes: 0

Views: 153

Answers (4)

Buzz
Buzz

Reputation: 6330

Instead of using bind , use ON method

   $("#upload, #browse_product_detail_file").on("click", function(event){
    });

Upvotes: 1

Sender
Sender

Reputation: 6858

Its very old way try this way.

As of jQuery 1.4 we can bind multiple event handlers simultaneously by passing a map of event type/handler pairs:

OLD

$('#foo').bind({
  click: function() {
    // do something on click
  },
  mouseenter: function() {
    // do something on mouseenter
  }
});

NEW

$('#foo').bind('mouseenter mouseleave', function() {
  $(this).toggleClass('entered');
});

Upvotes: 0

Krzysztof Jabłoński
Krzysztof Jabłoński

Reputation: 1941

This site looks remarkable. Maybe instead of obsolete bind, you should also think of using 'click' jQuery function.

Upvotes: 0

Shannon
Shannon

Reputation: 570

I might be mistaken, I've never seen click: written like that, try this:

$("#upload, #browse_product_detail_file").bind('click', function(){
    $('#product_master_csv_file').click();
    return false;
});

Upvotes: 0

Related Questions