Yii Framework Forum: Custom Module Code - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Custom Module Code where to put pieces Rate Topic: -----

#1 User is offline   mayelamingi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 16-August 13

Posted 15 November 2013 - 01:53 PM

I'm new to Yii (couple of months). I have a custom site before Yii, that draws a graphic representation on a canvas object on the screen, using javascript, based on data from several mysql tables. So I started by using Gii to create a custom module.

OK, now I register my js, javascript file, and I want it to grab some values from the web page using the dom. But the scripts are all placed in the header, so they can't read the DOM yet. My javascript code functions properly, and I can call functions to draw shapes on the canvas. But I'm having trouble just grabbing a value from the HTML.
Question 1. How do you register a custom javascript file so that it is placed in the body. I'm seeing lots of other simple solutions, but within the Yii environment its not always easy to find.

Once I have the key ID from the page, I want to use AJAX and Jquery to get some values from several mySQL tables...so that I can incrementally update the page with the graphics. No way that I can see to do it with the built in models, I have to write my own sql calls.

Question 2: Is this a situation where it is better to use DAO calls,instead of the built in Yii functions? I would rather be able to use the db object in the config file, which works fine in their own models with their one table, but what is the best strategy for doing custom sql searches?


Note: think I've found the answer to question 1: parameters of registerscriptfile allows us to change location of the javascript resources.
0

#2 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,701
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 15 November 2013 - 02:48 PM

1. just add your code to ready() section.
It can be done using POS_READY value.
See this: http://www.yiiframew...erScript-detail
(btw I wonder if it's default value)

2. Yii already has built-in DAO: http://www.yiiframew...en/database.dao
God is real unless declared as integer
0

#3 User is offline   mayelamingi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 16-August 13

Posted 15 November 2013 - 09:16 PM

View PostORey, on 15 November 2013 - 02:48 PM, said:

1. just add your code to ready() section.
It can be done using POS_READY value.
See this: http://www.yiiframew...erScript-detail
(btw I wonder if it's default value)

2. Yii already has built-in DAO: http://www.yiiframew...en/database.dao



Thank you, I'm working through those now.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users