Custom rules

Sometimes you don't want certain pages to be requested by the ajax script, for example an administration page, trackback link, feeds, etc. Thats why we have custom rules.

If you can't use these rules, you can mark each link you want to discard by adding the class "bda_ignore" or mention "bda_ignore" somewhere in the url, for example "http://www.bydust.com/something/?bda_ignore".

Custom rules for links

With custom rules for links we specify which links to discard, for example links to feeds or links to a page without our content area's. Links to filetypes included in our disallowedExt parameter are discarded automatically, the same goes for links on another domain.

We can add links to these custom rules using the code below:

Code


bda.denyURLRules.push('url.contains("/wp-admin/")');
// by adding this rule we discard all links containing "/wp-admin/", for example "http://www.bydust.com/wp-admin/edit.html".
// this is an example used for Wordpress implementations, wp-admin is the folder used to reach the Wordpress administration.

bda.denyURLRules.push('url.contains("/feed/")');
bda.denyURLRules.push('url.contains("/trackback/")');
// discards links containing "/feed/" and "/trackback/", also used for Wordpress implementations.
As you see, we can add rules easily. They are not really needed since our script will open pages it cannot parse in a new window or tab, but it improves the usability because it doesn't give any errors.

Custom rules for forms

We already discussed custom rules for links, but there are also custom rules available for forms.
They work in the same way, but this time we base the rule on the url specified in the action-attribute of the form element.

Code


bda.denyFormRules.push('action.contains("wp-comments-post.html")');
// this rule tells the script not to interfere when a form is posting to a file called "wp-comments-post.html".
// this is a Wordpress file, the script cannot post comments through ajax with the current Wordpress architecture.
// should be fixed soon tho :)
If you're using this class in a Wordpress installation, you need to specify this rule if you want people to be able to post comments. I'll fix it soon, just can't figure it out atm...
It's probably something stupid :(

Custom rules for notifying

We can also notify the server whenever a certain link is clicked, but don't show a return value on the page. We can use notify rules for this, they work in the same way as the above rules.

Code


bda.notifyRules.push('action.contains("notifyme.html")');
// with this rule we tell the script to post the information, but ignoring the server result.
// can be usefull if you're posting a form or clicking a link where you don't want any result from.