Showing posts with label jquery. Show all posts
Showing posts with label jquery. Show all posts

Wednesday, December 14, 2011

CKEditor plugin + grails submitTorRemote == fail

so people in my office talked to me now a couple of times that they like to have a formating option for text in the comment field.

So my first thought was to use the mighty ckeditor and there is a grail plugin already around. SO we should be done with this in 5 minutes...

Wrong it took a bit longer, since my form kept refusing to save my content and always reported the original content instead.

After quite a bit of googleling and the mandatory
I'm pissed about grails beer, this time it was a nice Aventinius

I found a solution to make it work.

Basically if you want to use CKEditor with JQuery you need to update it fields before (the plugin should really handle this! Do you hear me? I mean I fixed to many plugins by now...)




<g:form name="createNewComment" id="createNewComment" controller="comment">


<ckeditor:editor height="300px" width="80%" name="text ">

test
</ckeditor:editor>

<g:hiddenField name="id" value="${id}"/>
<g:hiddenField name="type" value="${type}"/>
<g:hiddenField name="destination" value="${destination}"/>


<g:javascript>
function CKupdate() {
for (instance in CKEDITOR.instances)
CKEDITOR.instances[instance].updateElement();
return true;
}
</g:javascript>

<g:submitToRemote before="CKupdate();" class="save" action="saveAjax" update="${destination}" value="save comment"/>


</g:form>




And this is all, now before we press the button, we always call the method to update the editor and everybody is happy...

Friday, December 9, 2011

jQuery + grails and my missing buttons...

currently I'm switching miniX over to use jQueryUi style buttons, since this makes life so much easier to maintain them.

Except during my event processing my buttons keep disappearing, which is rater annoying, to say at least.

Couple of hours later I finally found a crude but working solution. I just create a simple event handler, which re renders all by buttons...


$(document).ajaxComplete(function() {
$("input:submit, a.button, input:button, div.qq-upload-button").button()
});

$(document).ready(function() {
$("input:submit, a.button, input:button, div.qq-upload-button").button()
});

Monday, August 8, 2011

grails + jquery + checkboxes

sometimes forms based on checkboxes can be rather annoying. An example would be that this is the return of a standard html checkbox,

html defined checkboxes:

<g:checkBox name="compare" id="1"/>
<g:checkBox name="compare" id="2"/>
<g:checkBox name="compare" id="3"/>


result of the send parameters to the server:



def compareBins = {
println params
}

out:

compare:[on, on, on]


now this is rather useless, we rather would see the id of the checkbox in the result. So let's call jQuery to the rescue and see how it can save out day!



jQuery(document).ready(function() {
$('input:checkbox').each(
function() {
$(this).click(function() {

if (this.checked) {
var value = $(this).attr('id');
$(this).val(value);
}
});
}
);
});



and promptly we have the following result if all 3 boxes are selected


compare:[1,2,3]


or if 1 and 3 are selected


compare:[1,3]


so we can actually tell, which elements where checked instead of getting just 'on'

Tuesday, August 2, 2011

MedPlan

Over the last couple of days I was thinking about creating a small grails to show the speed of development with grails. The goal was to create an application in less than 24h, which is able to track your medications and at the same time has some important features.

The original idea came from spending the last 5 days with my wife's sick sister and see how difficult and confusing it was to track all her different medications. Specially since there were 3 people involved doing this and nobody really know, which medications did she already receive.

What does the user want:

  • easily enter a new prescription
  • see which medications have been taken
  • show when to take a medication
  • show the medication's in form of a calendar

What did I want as a developer:
  • easy to use
  • multi user access
  • ajax driven/jquery
  • calendar interface
  • auto complete
  • multi platform support (ipad/windows/linux/osx)
  • able to run without a tomcat installation
  • don't look like a standard grails scaffolding application
  • use as few mouse clicks as possible
how does it look after 16h of work?

weekly overview

prescription overview

adding a prescription

What is missing?

I think at this point in time the application does what it's supposed todo, but some nice features would be:

  • iPad support as a native application
  • internationalization
  • share your prescription plan with another user
  • send out an email, 30 minutes before a medication has to be used
  • soap/rest based access 
Where can I get it?

You can download the application here