What is a path from Ctools Modal to Modal Frame API - drupal

I wrote a module that uses the Ctools Modal Window to serve a form wizard. I would like to switch to using the Modal Frame API (which uses the JQuery UI Dialog as the modal). If someone has some experience making this type of switch in their code and can give me some pointers, I would appreciate it.
Thanks,
David
Update:
So I finally got around to making this change and this is what I learned:
On the server side code replace
ctools_modal_add_js() with
modalframe_parent_js()
On the client side js code where you
may do
$('#modal_link').click(Drupal.CTools.Modal.clickAjaxLink);
Replace
Drupal.CTools.Modal.clickAjaxLink
with your own custom function.
Clearly the ctools modal window is way easier to use because in most cases you wouldn't even have to bother with creating any js like above. But, there you have it.

I have never used CTools, but the Modal Frame API is very straight forward to use. You can have a look how I used it in my Sticky Notes module.
The documentation of ModalFrame API is quite comprehensive.

So I finally got around to making this change and this is what I learned:
On the server side code replace
ctools_modal_add_js() with
modalframe_parent_js()
On the client side js code where you
may do
$('#modal_link').click(Drupal.CTools.Modal.clickAjaxLink);
Replace
Drupal.CTools.Modal.clickAjaxLink
with your own custom function.
Clearly the ctools modal window is way easier to use because in most cases you wouldn't even have to bother with creating any js like above. But, there you have it.

Related

Possible to generate UI runtime in Windows Store apps (Metro)?

We're currently researching if it is possible to on the fly generate/change the UI of a metro app. So far I have seen only that the reflection options are somewhat limited. But perhaps if we're using HTML/JS we can modify the HTML on the fly? Anybody tried something like this?
Will fire up VS later and give it a go, just thought I'd ask here and see if we could have a disucssion on the topic.
Most Javascript-based apps modify their HTML on the fly as this is a pattern promoted by the Navigator template. So for example even just clicking a link and navigating to another page will replace the content of a 'page' container element instead of reloading the whole page and thus reloading all .js and .css files.
Also the WinJS.UI.ListView will dynamically create and reposition elements in your DOM as you scroll its contents.
Basically you can do anything you'd do in a webapp and re-use patterns like known from AJAX to make your UI adapt dynamically.
Depending on what you want to achieve, you should with increasing complexity keep in mind that your app should be able to suspend and restore its state from scratch at any point.

asp.net: dynamically extend content

i'm not sure how to call that. i'm looking for some samples guiding me how to implement a automatic page extend. i'm mean something like the friends list on facebook. first only a few friends are loaded. after you scroll down, some others get loaded.
thx in advance
The solution to your problem relies more on AJAX then anything else.
I suggest using jQuery Ajax, and here is a nice article that will get you started with calling ASP.NET web services via client side script.
enter link description here
If you don't have experience using ajax this will probably be a lot for you to grasp. Especially if you're going to dive in with a feature like you described above.
Edit: It may be more practical to use a plugin to achieve this:
scrolling jQuery plugin

How to use jquery selectors on json result

I'm creating an inbox system for my website which allows basic communication between users. I'm fetching the results with jquery calling a webservice.
Then I'm using a jquery template engine to render the results to the screen. So far this all works good. but now I want to add some click functions on certain parts of inbox messages. For example I want the title of the message to be clickable so it will expand/collapse the fulltext which is hidden in a div beneath it.
But I can't seem to use the jquery selectors on this dynamic json result. It works when I put the function in the href tag itself but I don't really want to. I also tried adding the function after the success function but no luck either. Is it possible at all to use selectors with a template engine?
I hope I made myself clear otherwise feel free to ask more information. Thank you very much
Kind regards,
Mark
Have you tried jquery .live option? http://api.jquery.com/live/
I'm sorry, you'll see it happens all the time, when something goes wrong and I ask a question the minute after it it solves itselves. It is indeed possible to use the jquery selector on dynamic elements. Just make sure u put it after the template processing and in the ajax success function.
Thanks.
Are you trying to select the json that is returned from the webservice or are you trying to use the jquery selector to find an element that you added previously on to the page?

Implementing Timeout Javascript in a PeopleSoft iScript

Regular PeopleSoft components automatically generate a timeout popup window when a user is about to be logged out. iScripts, however, do not.
I was about to reverse-engineer the javascript that PeopleSoft automatically generates for components in order to leverage existing code.
Before I do, I thought I'd check if anyone else has done this, and if there are any gotchas, tips or tricks. Or maybe there's a better way?
I reverse engineered how the Navigation Collections page (which is an iScript) works since it also handles timeouts. The solution is relatively simple.
First, include the results of %Request.ExpireMeta (PeopleCode function) in the portion of the HTML you generate.
Secondly, include the delivered javascript PT_SAVEWARNINGSCRIPT in the HTML you generate.
Finally, have your iScript call the javascript function setupTimeout().

How to use client side code in Visual studio ASP.NET

I am a quite new to web development and I am trying to do some small form updates without causing a postback. For example making a control visible when a drop down list is changed.
I have so far come across some features that achieve this like the RequiredFieldValidator inside an update panels. However, these are specific to a single task.
What are my options to achieve these client side updates in Visual Studio? At the moment I don't know any JavaScript, so I would prefer another solution if it exists.
If you don't know JQuery you should or at least any other Javascript library this will give you an edge and also pump up your resume. The learning curve of these JS frameworks is so short that you'll be creating awesome UI's in no time. I suggest that you take at least two hours to get to know JQuery you won't regret it.
Here's a few great article on using ASP.NET with JQuery:
http://dotnetslackers.com/articles/ajax/using-jquery-with-asp-net.aspx
http://www.dotnetspark.com/kb/1532-gridview-and-jquery-asp-net-tutorial.aspx
http://www.beansoftware.com/ASP.NET-Tutorials/Using-jQuery-ASP.NET.aspx
Here are a few of the best tutorials on JQuery:
http://www.ajaxline.com/best-jquery-tutorials-march-2010
For display functionality like you have described, javascript really is the best solution. Take a look at jQuery, it makes writing javascript a lot easier, and you should be up and running with it in no time for tasks like your basic show/hide functionality.
Unfortunately, AJAX stands for 'Asynchronous Javascript and XML' so getting this behaviour without using Javascript is going to land you in a bit of a pickle.
Update Panels do work and are very easy, but they're also very slow in comparison as even if you only see the contents of your panel update, the entire ASP page has to be executed.
I'd urge you to take a deep breath and head over to JQuery.Com and practise the tutorials there. Javascript is easier then you think and JQuery takes a lot of the hardships of cross-browser compatibility out of the picture, leaving you to focus on the real tasks.
Good Luck!

Resources