Two forms in the same file

0

I have an index.php file where I have two panel-tab, each one with its own form, inputs and buttons. Handle all events with jquery in a script.js file. Everything was fine with the second panel and its elements until I try to create the event $('#btnGuarda').on('click',function () {}) , which is a button to save the form of the first tabpanel, and I get this error when I click on the button:

jqxcore.js:7 Uncaught Error: Invalid Selector - #jqxgrid! Please, check whether the used ID or CSS Class name is correct.

(# jqxgrid is a grid, but gives the same error later with all the elements of the second form)

Any idea why this error is due?

    
asked by daniel2017- 13.09.2016 в 16:07
source

1 answer

2

Do you have imported more than one Jquery library? I think it's because the object you're calling does not correspond to a jquery library but to a jquery widget, in this case it seems to be JQGrid.

You can try to use a variable to avoid conflicts:

<script src="otra_libreria_jquery.js"></script>
<script src="jquery.js"></script>
<script>
      var $j = jQuery.noConflict();
</script>

Now instead of calling the listener using $, you must do it using $ j, or the name that you give to that variable.

$j('#btnGuarda').on('click',function () {})

I hope I could have helped you, I do not know if you are really importing other jquery libraries but because of the error it seems that yes.

Greetings.

    
answered by 13.09.2016 в 16:31