I can't get Netbeans to auto-complete my selectors for JQuery, example:
<a id="hello" href="#">Hello</a>
<script type="text/javascript">
$("|").hide();
</script>
As far as i understand the documentation at this point it should show the tags available on the page when i press control+space at the | position, but instead displays no suggestions. Links [1] and [2] shows clearly that this has been implemented. I have not tried prototype, link [2] shows that JQuery support has been added as well.
The auto-complete of functions works perfectly, with the embedded library of JQuery 1.4.2, it is only the selector auto-complete that does not work. Any suggestions?
[1] http://wiki.netbeans.org/JavaScript#Embedded_Completion
[2] http://wiki.netbeans.org/JavaScript#Recently_Added
Product Version: NetBeans IDE 6.8 (Build 200912041610)
Java: 1.6.0_18; Java HotSpot(TM) Client VM 16.0-b13
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
5 years later update:
As of at least version 8.0.2 Netbeans now properly auto-completes jQuery selectors in both php and html pages. I am unsure if this is due to some other changes on the editor engine or they finally caught the discrepancy but either way it works now, yay!
Naor answer made me rethink what I was doing, but it didn't quite answer my question. So let me provide the solution I found in case anyone is interested.
When working with netbeans, the auto-complete function behaves differently between php files and html. In html jquery selectors auto-completes as expected. But when trying to do the same within a php file in an html section of code, it will fail to auto-complete.
Just make sure that if you are expecting this feature to work, that you are using html files, not php. I will submit this as a feature/bug to the netbeans guys, hopefully they can fix it and make html/js auto-completion available to all file types that can include html/js code.
Link 1 says that there is code completion on element ids that appear in the html itself. They also say that it works with Prototype.js. I believe that it would work for jquery too, but don't forget - in order to select an element using it id in jquery you do $('#id') - with #.
What they meant in their example if you have $("f|") is that if you start writing $("f and the cursor of typing is after the f (they put "|" in order to mark the cursor), then code completion should show all relevant elements.
Try that:
in html: <div id="blabla">12345</div>
in jscript: $('bl');
after the bl press control+space, and I believe that it will display to you blabla.
Related
Sublime Text - Version 3.0, Build 3143
I deal with a lot of php files that contain HTML, CSS and JavaScript. The only problem I've found so far is when I'm looking at script tags in a PHP file. The syntax is set to PHP but comments outside of JS functions break the rest of the code below it (it looks like it's trying to detect regex?)
When I move the // test comment into the function then all is well:
I'm curious to know where the problem exists and maybe find a fix.
Color Scheme doesn't affect the syntax highlighting (it still breaks in other color schemes)
Adding type="text/javascript" to the script tag doesn't fix anything
My finger points to the PHP syntax highlighting ... but if that's the case, how can this be fixed?
Fresh install of Build 3143(Windows), opened as "PHP" and everything works. It can be caused by some custom settings you made or third party plugin.
When we had done security audit of our project, we got broken Link "/a" vulnerability.
After searching for link throughout project we found link in JQuery-1.9.js java-script file that we are using in our project.
small part of code in that JQuery-1.9.js -
// Make sure that URLs aren't manipulated
// (IE normalizes it by default)
hrefNormalized: a.getAttribute("href") === "/a",
As per my understanding this code part helps for making it(JQuery) compatible with IE 6/7/8.
hrefNormalized is used to check that anchor tag is giving href value as full URL or exact href , which is issue in IE version.
The better explanation of this part is given in
https://www.inkling.com/read/jquery-cookbook-cody-lindley-1st/chapter-4/recipe-4-1
I want to remove this vulnerability but i don't want to remove or change code in JQuery js file.
So, My question is why did not JQuery designers used "/#" instead of "/a" .What is the problem of using "/#" in that code.
Earlier same question is asked by someone to JQuery Team,but they told that it not the problem from Jquery.
For reference of that ticket
http://bugs.jquery.com/ticket/10149
Help me to solve Or Is there another solution?
Thank you
This is not a vulnerability but a false positive. The security scanner interprets the "/a" string as a link, which it is not.
Even if jQuery creates the link in the DOM, it's not clickable or visible to the user. Your website does not actually have a real link to /a anywhere.
I would ignore the problem without changing anything.
Maybe, if you want this hrefNormalized: a.getAttribute("href") === "/a", to be transformed into this hrefNormalized: a.getAttribute("href") === "/#", but you don't want to touch the jQuery file.
Put that second one in a script in a an order so that the browser reads your script after reading the jQuery file, so it mashes.
Anyway, I never had issues with jQuery before, check your code first.
If you don't want to have your views with scripts, put it in a js file and link this file to your view after the jQuery file.
Hope it helped you, or at least gave you some ideas to solve your problem. Good luck, let us know how it goes! ;)
EDIT:
<script src="~/JQuery/jquery-2.0.3.js"></script>
<script src="~/Scripts/Fix.js"></script>
If you do something like this, the browser reads first the jQuery, then it reads the Fix.js. Inside the Fix.js, you put the function or paramater you want to change from the jQuery.
So the Browser will get the latest one it reads if they are equal.
For example:
function whatever (){ //This in jQuery file
//things #1
}
function whatever (){ //This in Fix file
//Different things #2
}
This way the browser chooses the Fix.js one, because was the last he read.
I found a "scroll to fixed" sticky navigation that I love, but I'm having trouble getting it to work at my site - http://codepen.io/Guilh/pen/JLKbn
The problem is, they are using JQuery.min - http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js and my Wordpress site is using JQuery, the same version 1.11.0, but without the min in the URL.
When I test the code out locally, the JQuery.Min link works, but not my JQuery, even though they are both 1.11.0. Is there a difference? The code in the two files looks exactly the same, but one works and the other does not. I thought min just meant minified so that it is a shorter file and faster load.
Sorry. I "need 50 reputation to comment". Have you tried seeing if $ is defined? In some CMS's they run jQuery in no conflict mode so you have to use jQuery instead of $. To find out go to your firefox console and type in $ and hit enter. Then type in jQuery and hit enter. That will tell you if it's undefined or not.
If you want to use $(function(){/*code here*/}); but still use $, you can pass it using jQuery(function($){/*code here*/});. This is all assuming you are running in noConflict() mode.
Does anyone know how to make a live text highlighter in javascript/jquery? with most script ive seen, you have to select the text first then click highlight. how does diigo.com do it?
Simple javascript can not provide functionality like diigo.com.
You need to write browser plugins.
This type of plugins are called BHO (Browser Helper Object)
Creating BHO need some experience and understanding of COM.
See the examples below
Exaple 1
Exaple 2
Example 3
To work with JS files in Visual Studio 2008, I did:
Tools -> Options -> Text Editor -> File Extensions
and added js extension with Script editing experience.
That works pretty much as expected apart from the following things:
Syntax highlighting is set-up extremely slow (after 10 seconds or so) when I open the JS file. The compiling warnings are generated equally slow and they disappear slowly when fixed. Generally, not a big deal, but I wonder why. Until the file is syn highlighted, you can't put in breakpoints.
Intelisense works, but not always. For instance, if I use getElementById to get the element, intelisense with that element doesn't work. I guess it has to do with context, as the compiler can't determine what kind of object is in question. It also doesn't work inside an html page using the script tag, but in this case syn highlighting is immediate.
If there is any better approach?
I am currently opting to use an external editor and to launch it by adding a custom "open with" action on js file. However, I don't like doing this because I can't use the fantastic VS debugging capabilities...
The 3rd party addin Visual Assist X can help with js.