No PJAX functions work apart from one - html

I have a PHPBB forum along with PJAX.
PJAX works well with links however whenever I try use a .pjax function I get an error in firebug, claiming that .pjax is not defined?
Here is what works:
pjax.connect('wrap');
Here is what doesn't work:
$(document).pjax('a', '#pjax-container')
$.pjax.submit(event, '#pjax-container')
and anything that contains .pjax.
I have the pjax/pjax-standalone.min.js file included in my header.
Am I misunderstanding something here?
Thanks,
Peter

Related

PhpStorm - Choose which SASS-files to show autocomplete from first

I'm working on a project that has:
Bootstrap
FontAwesome
It's own custom stylings
When I write something like this:
.some-el {
font-size: $f (and then wait)
}
Then it thinks for a second and then suggests something like this:
$focus [my variable]
$fa-font-display [implicitly imported from font-awesome]
$fa-font-path [implicitly imported from font-awesome]
$fa-css-prefix [implicitly imported from font-awesome]
$font_size_base [my variable - that I was looking for]
...
...
It gets better with time, since it remembers what I've used previously - so I guess this is something that would fix itself. But it would be awesome to be able to fix it myself right away.
This is just an example where FontAwesome-variable are a nuisance, but other times it's the Bootstrap-variables.
How can I define which SASS-variables that are suggested (and/or the order of the suggestions)?
Solution attempts
Googled a bunch.
Looking through settings for 'Code Completion' and 'Code Style'
It's not possible. The only way I can think of is excluding the folder where the .css/.scss files you don't like getting completion from are stored from indexing (Mark directory as/excluded).
Related feature request: WEB-41257

use a class instead of id in a link

Is it possible to make a link that would normally go to an id:
<a href="http://example.com/page#someid">
instead go to a class:
<a href="http://example.com/page.someclass">
Would the page scroll wildly up and down, trying to reach all the elements with that class, or would it just do nothing?
It would do nothing, except look for a file called "page.someclass" at the server and most probably yield a 404. Please refer to the URL spec because you're wildly confusing CSS selectors with the 'hash' part of the URL.
Why don't just try it?
JS FIDDLE DEMO
If you are using a class als anchor link, your browser tries to open it as url, like in the example named above index.content. Because he is not able to find it, you will receive an 404 not found or 403 forbidden error.

How to build a templated link?

I have a method with a request parameter and I'm trying to link to this method from another resource. I want the link to be something like this:
"rel":{
"href":".../resources{?param}",
"templated":true
}
I tried the following without success:
//First attempt
resources.add(linkTo(methodOn(Controller.class).method(null)).withRel("rel")
//Second attempt
resources.add(linkTo(methodOn(Controller.class).method("{parameter}")).withRel("rel")
//Third attempt
resources.add(entityLinks.linkToCollectionResource(LinkedResource.class).withRel("rel");
It does work now, you can check the following issue which has been resolved now - https://github.com/spring-projects/spring-hateoas/issues/169.
As you have mentioned above in your first attempt -
resources.add(linkTo(methodOn(Controller.class).method(null)).withRel("rel")
should work.
This isn't currently a part of spring-hateoas, see this open bug report, which suggests adding this functionality to ControllerLinkBuilder and this previous question which has an answer with a custom implementation for doing this.

How to Include "onclick" Object in WordPress HTML

I'm using attempting to add an "onclick" object to a page in a singlesite (i.e. rather than multisite) WordPress that triggers an event. The code is:
Send a voice message
When attempting to save the code, WordPress strips the onclick object leaving:
Send a voice message
A user on another forum suggested that this restriction should only apply to multisite non-superadmin users. Again, this is a siglesite with only one admin user.
It is understood that WordPress removes "onclick" from HTML to prevent malicious code. Still, does anyone know how to resolve this?
Thanks.
It appears that with current Wordpress (I'm on 4.9.4), TinyMCE does the filtering directly on the editor screen, not when the form is submitted. The allowedtags and allowedposttags don't seem to matter, so the solution above does not solve the problem for me.
The method I have developed uses the tiny_mce_before_init filter to alter the allowed tags within TinyMCE. The trick is to add the extended_valid_elements setting with the updated versions of the elements allowed for a.
First, look in the page http://archive.tinymce.com/wiki.php/Configuration3x:valid_elements to find the current value for a, which right now is
a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur]
And add to the end of that the onclick attribute:
a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick]
Then use that in the filter function like this:
function allow_button_onclick_mce($settings) {
$settings['extended_valid_elements'] = "a[rel|rev|charset|hreflang|tabindex|accesskey|type|name|href|target|title|class|onfocus|onblur|onclick]";
return $settings;
}
add_filter('tiny_mce_before_init', 'allow_button_onclick_mce');
which you install in your functions.php file in Wordpress. You can see it in action by toggling the text and visual view on the edit page. Without the extended list, the onclick goes away. With it, it remains.
You can solve this by changing the anchor tag into button and adding a script. For more info please refer to this link: Wordpress TinyMCE Strips OnClick & OnChange (need jQuery).
By resolving, I'm assuming you mean to allow the onclick attribute. You will want to be careful with this, because modifying the allowed tags does this for all your users.
You can modify the list of allowed tags and attributes, by adding this to your functions.php file:
function allow_onclick_content() {
global $allowedposttags, $allowedtags;
$newattribute = "onclick";
$allowedposttags["a"][$newattribute] = true;
$allowedtags["a"][$newattribute] = true; //unnecessary?
}
add_action( 'init', 'allow_onclick_content' );
I suggest trying it with only $allowedposttags first to see if that works for you. According to this other stackexchange post, you should only need allowedtags if you need it for comments or possibly non-logged-in users, but when I did something similar in the past, I needed both of them to work.
On a side note, if you want a list of all already allowed tags and attributes, look inside your /wp-includes/kses.php file.

CodeIgniter increments/counts page views twice, not once

I am simply trying to increment the amount of page views per visit with CodeIgniter's active record. For some reason, the following code is incrementing twice. So it adds 2 page views per visit. What is strange is that this is used on another website that shares the same table and the same method code and it works properly on the other website. The views field is a simple int(11). I am only calling this method once in the controller, I thought maybe I had a duplicate but I do not.
function increment_video_view($video_pk) {
$this->db->where('video_pk', $video_pk);
$this->db->set('views', 'views+1', FALSE);
$this->db->update('videos');
}
Any ideas or help would be great! Thanks!
Try putting an echo (or log) statement inside the function to see if it actually gets called twice. Let us know if it only echo's once.
function increment_video_view($video_pk) {
echo "We in increment_video_view";
$this->db->where('video_pk', $video_pk);
$this->db->set('views', 'views+1', FALSE);
$this->db->update('videos');
}
Are you sure that the controller is executed only once?
This happens when you have a 404 link (image/css/favicon) in your HTML, or if you have a missing favicon.ico
Chrome looks for a favicon.ico even if you don't insert it in your HTML, and when it finds it missing, I think it calls another request.