ajaxLink with JS disabled

Is there a way so that the url still goes to the ‘url’ property on the ajaxLink button if javascript is disbled?

eg.




echo CHtml::ajaxSubmitButton('Delete', array('/item/delete', 'id' => $item_id), array());



the above link would run whatever ajax was applied to it but if I have js disabled it will still link to ‘/item/delete’ action.

Cheers

If JS is disabled the form - by default - would submit to the action that rendered the page but you could set the form configuration to ‘action’=>array(‘item/delete’) so that it still will be sent to this action even if JS is disabled.

Cheers

I think you might be referring to ‘ajaxSubmitButton()’ rather than ‘ajaxLink()’.

For the ajaxSubmitButton() it is all fine but ajaxLink does not do anywhere with JS disabled

Sorry!

just realised my post was talking about submitButton

What I actually meant was the ajaxLink function

The difference is that a ajax submit button has a natural fallback (as it is a submit button within a form thus using the classic html submit when js is disabled) while the ajaxLink has none. I think you would have to implement that by yourself

Here is the code:

http://www.yiiframework.com/doc/api/1.1/CHtml/#ajaxLink-detail

It seems that the href entry is set to ‘#’ by default. You could play around with this parameter setting the htmlOptions array like this:

echo CHtml::ajaxLink(‘Delete’, array(’/item/delete’, ‘id’ => $item_id), array(‘htmlOptions’=>array(‘href’=>‘youractionurl’)));

This is just a very dumb example but maybe it gets you on the right track