Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring init.js of Designer #15338

Merged
merged 1 commit into from Jun 18, 2019

Conversation

Bournvita1998
Copy link
Contributor

Signed-off-by: Bournvita1998 mohit.kuri@research.iiit.ac.in

Description

Refactoring in the init.js of the designer section

Fixes #

Before submitting pull request, please review the following checklist:

  • Make sure you have read our CONTRIBUTING.md document.
  • Make sure you are making a pull request against the correct branch. For example, for bug fixes in a released version use the corresponding QA branch and for new features use the master branch. If you have a doubt, you can ask as a comment in the bug report or on the mailing list.
  • Every commit has proper Signed-off-by line as described in our DCO. This ensures that the work you're submitting is your own creation.
  • Every commit has a descriptive commit message.
  • Every commit is needed on its own, if you have just minor fixes to previous commits, you can squash them.
  • Any new functionality is covered by tests.

Signed-off-by: Bournvita1998 <mohit.kuri@research.iiit.ac.in>
@ibennetch ibennetch merged commit 0509497 into phpmyadmin:gsoc-db-designer Jun 18, 2019
@ibennetch
Copy link
Member

Good job.

@@ -54,22 +54,22 @@ AJAX.registerOnload('designer/init.js', function () {
}

$('#query_Aggregate_Button').on('click', function () {
document.getElementById('query_Aggregate').style.display = 'none';
$('#query_Aggregate').style.display = 'none';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bournvita1998 shouldn't we be using $("#id").css("display", "none"); or $("#id").hide(); here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devenbansod I didn't find a good article comparing the difference between these 3. I know they all does the same job but no idea what's the difference. Can you help me knowing the difference between them?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devenbansod, for now, I am thinking of moving ahead making the changes in a similar way as I have done here. If required, we will change them again.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Bournvita1998 have you tested this in the browser?

AFAIK, $('selector') returns an array-like JQuery-native object and doesn't return a native DOM element. So if I'm not mistaken, this code change would throw an error: Uncaught TypeError: Cannot set property 'display' of undefined in the console.

Ref for the css API: https://api.jquery.com/css/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@devenbansod Yeah you are right here. $('selector') will return an array of all possible matches but document.getElementById('ID') returns just the first match it finds. To resolve this error we can either do the things as you suggested in your first comment or we can change $('selector') to $('selector')[0]. I found this on stackoverflow explaining the difference between jQuery object and DOM elements.

Also, I found the same issue in my previously created PRs too, which need to be changed soon. I am thinking of replacing them using the css format like: $("#id").css("display", "none"); is that fine to move ahead?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, please go ahead 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was indeed invalid: #16960

@williamdes
Copy link
Member

Gosh, why did I approve this invalid code.. 🤦🏻
Ref: #16960

williamdes added a commit that referenced this pull request Jun 11, 2021
Error created by pull-request #15338 in fec7de8

Signed-off-by: William Desportes <williamdes@wdes.fr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants